public class CustomDataGrid : System.Windows.Forms.DataGrid
{
//this override will prevent the cell in row 1 from getting the edit focus
protected override void Edit(System.Windows.Forms.CurrencyManager source,
int rowNum, System.Drawing.Rectangle bounds, bool readOnly, string
instantText, bool cellIsVisible)
{
if(rowNum == 1)
return;
base.Edit(source, rowNum, bounds, readOnly, instantText,
cellIsVisible);
}
}
codeproject.com has some good examples... also check this link
http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx
VJ
> Me too I have tried:
> 5.18 How can I prevent a particular cell from being editable?***
[quoted text clipped - 13 lines]
>
> *** Sent via Developersdex http://www.developersdex.com ***
adh - 16 Apr 2006 06:30 GMT
To VJ,
Thanks I'll try it out.
As for
http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx
none of them gave a solution (not in VB2003)
Thanks, adh
adh - 17 Apr 2006 18:31 GMT
TO VJ II
Thanks, I tried out: protected override void Edit(.....
without success. My project is a VB.NET (2003) and I could not fix the
translation of your C# proc. to VB.
Could you please send it to me?
Thanks, adh
Anant Tiwari - 04 Dec 2006 06:17 GMT
hi
This is the vb.net form you have to just copy paste the below code in
subroutine into mouse up event of the datagrid
Hope this will solve ur problem
Private Sub dataGrid1_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles dataGrid1.MouseUp
Dim pt = New Point(e.X, e.Y)
Dim hti As DataGrid.HitTestInfo = dataGrid1.HitTest(pt)
If hti.Type = DataGrid.HitTestType.Cell Then
dataGrid1.CurrentCell = New DataGridCell(hti.Row, hti.Column)
dataGrid1.Select(hti.Row)
End If
End Sub