Sam Hobbs
posted
6447 posts
since
Sep 07, 2009
from
Los Angeles, California, USA
|
|
Re: DataGridView - Allow Editing on single column
|
|
|
|
|
|
|
|
|
|
Well, let's see. Does the DataGridViewColumn class have a ReadOnly Property? I see one. So it seems to me that the worst case is that you set each column to ReadOnly except one.
|
|
|
|
|
Thinking is a feeling; pleasant for some and unpleasant for others.
|
|
|
|
|
|
Andrew
posted
7 posts
since
Oct 05, 2009
from
|
|
Re: DataGridView - Allow Editing on single column
|
|
|
|
|
|
|
|
|
|
|
Hi Sam, thanks for your reply. I thought that may also be an option but whether i set ReadOnly on the individual columns to true or false it is overridden by the flag on the datagridview as a whole. I should have mentioned also that im populating the datagridview using sql and databind (so i tried setting each columns read-only property in code since i cant access through the usual properties window).
|
|
|
|
|
|
Andrew
posted
7 posts
since
Oct 05, 2009
from
|
|
Re: DataGridView - Allow Editing on single column
|
|
|
|
|
|
|
|
|
|
Hi All, i have found a solution to the problem but it wouldnt be my first choice so if anyone can think of a better way im still open to sugestions. On the cellClick event of the DataGridView i check what column the cell belongs to. If its the column i want to be editable i enable the whole gridview, otherwise i set the whole gridview to read only.
Private Sub dgExpectedAmounts_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgExpectedAmounts.CellContentClick
If e.ColumnIndex = 3 ThendgExpectedAmounts.ReadOnly =
FalseElsedgExpectedAmounts.ReadOnly =
TrueEnd If
End Sub
|
|
|
|
|
|
Andrew
posted
7 posts
since
Oct 05, 2009
from
|
|
Re: DataGridView - Allow Editing on single column
|
|
|
|
|
|
|
|
|
|
|
Slight amendment to my last post........
Putting the check on the mouseEnter event of a cell worked better.
Thanks all.
|
|
|
|
|
|