Hi,
For this, you can trap the row being clicked in the MouseDown event of the grid. Check for row number or its value and set the ReadOnly property of the grid to True:
Private Sub DataGrid1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseDown
Dim htinfo As DataGrid.HitTestInfo
htinfo = Me.DataGrid1.HitTest(e.X, e.Y)
Dim r As Integer
r = htinfo.Row
If r = 2 Then
Me.DataGrid1.ReadOnly = True
Else
Me.DataGrid1.ReadOnly = False
End If
End Sub
However, if you wish to make a row readonly when the grid is loaded, you can inherit from DataGridTextBoxColumn and create a customized Column Style
yourself, then you can override Edit method. Finally determine the value of the current edit cell and disable the edit function. See the following article on implementing a custom column style:
http://msdn.microsoft.com/library/de...classtopic.asp
Hope this helps.
Thanks
Mona [GrapeCity]
"ywchan" <yw****@gmail.com> wrote in message news:el**************@TK2MSFTNGP09.phx.gbl...
I would like to make some of the rows in the datagrid read only according to
certain condition.
How can I make some of the rows editable while others read only in a
datagrid? Thanks!