Protecting a single cell on a data grid

newtome

Newcomer
Joined
Aug 5, 2003
Messages
4
Can anyone help. I am having difficulty protecting just an individual cell on a data grid. Since it is column oriented, all I can seem to do is protect the entire colume. Thanks
 
If this protection is based on the data contained in that cell, you can trap the selectedIndeChanged event, then determine its' contents then discard or disaloow changes at that point.

As far as I know you can't do this during render/bind.
 
if you want to validate the data inside the column then the validation will apply to all the column,
else do the following,
use the yourdatagrid_MouseDown event, and write the following inside:

Dim hti As DataGrid.HitTestInfo = yourdatagrid.HitTest(e.X, e.Y)

If hti.Row <= yourdatagrid.DataSource.rows.count - 1 Then
If hti.Row = the_index_of_the_row_you_want Then
If hti.Type = Windows.Forms.DataGrid.HitTestType.Cell Then
If hti.Column = your_column Then
msbBox("You can't access");
End If
End If
End If
End If

Mohsen
 
Actually the protection is based on the data contained in the previous cell as to whether or not they have access to the next cell or not. Depending upon the actual type of information entered into the previous cell, I then need to determine whether or not to gray out and protect the following cell. I will try the ideas that you have given me so far. If you have a better solution based on this additional information, please let me know.
Thanks
 
Back
Top