|
I've been at this on/off for about a week now. I put it to the side & move onto other things and now I'm back to it.
I have a datagridview (dgvScheduleInfo). In its properties I have the "ReadOnly" set to true. I have 6 columns (0-5). The last column ("Notes") I want to make editable if someone clicks on a "Edit Notes" button. Sounds simple enough.
I've used the following code to no avail:
dgvScheduleInfo.Columns(5).ReadOnly = False
I've tried:
dgvScheduleInfo.Columns("Notes").ReadOnly = False
The code above errors out with a "Object reference not set to an instance of an object." even though when I step through the code it shows "Notes" as the name.
I've tried hard-coding a value for testing purposes:
dgvScheduleInfo.Rows(3).Cells(5).ReadOnly = False
and that hasn't worked.
And this is ultimately what I want to work:
dgvScheduleInfo.Rows(dgvScheduleInfo.CurrentRow.Index).Cells(5).ReadOnly = False
When I step through the code, I only get an error on the one I specified. Other then that though the code steps through fine but does not set the column I'm requesting to be editable.
Now yet another curveball...
If I use:
dgvScheduleInfo.ReadOnly = False
It works fine but turns ALL the cells on which I don't want. I only want the "Notes" (or column 5) to be editable.
I've changed the "EditMode" to a couple of different things as well. Nothing.
Hopefully it's something very easy I'm missing.
I haven't changed any of the properties on the datagridview control when I dropped it on my form either. Also I'm using a tableadapter and dataset to populate my datagridview.
The only code in my command button is what I've stated above.
Thanks for any help on this.
|
|
|
|
|
John Waclawski wrote: I haven't changed any of the properties on the datagridview control when I dropped it on my form either.
That's a shortcut that "generates" code in the background, and it might seem like everything works as if by magic; but as you noticed, it takes a bit more than dragging & dropping.
The update-procedure is described here[^].
Most of us will be loading data "by hand", not using the generated code from the designer.
|
|
|
|