Datagrid RowHeaderWidth changes to 15 when rebuilt

I have a read only datagrid in one of my forms. I use a context menu that has Edit to open another form to edit the values in the right clicked row. The editing form sets it's dialogresult to OK if the UPDATE SQL command terminates sucessfully.

When the form with the datagrid is returned to it rebuilds the datagrid to reflect the edited changes. This includes setting the TableStyle which sets values such as the Column Width, Column Field Name (of the datatable) and the Column Name. After the Table Style is set datagrid parameters are set such as AllowNavigation - False, BackgroundColor, ReadOnly - True, and RowHeaderWidth.

The RowHeaderWidth is 5, however, after this line is executed after an edit the RowHeaderWidth value sets to 15 and cannot be changed (I've tried in the Watch window).

During a step through with RowHeaderWidth in the watch when the .RowHeaderWidth = 5 line is executed the value in the Watch window changes to 15.

I've tried several values from 0 to 145 for the RowHeaderWidth but each time the value sets to 15.

Has anyone seen this happen?

Does anyone know what to do to keep this from happening?

[1532 byte] By [GilbertB] at [2007-12-29]
# 1
Set the TableStyle's RowHeaderWidth instead of the datagrid's.
KenTucker at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 2

Yeah that did it. It seems kind of strange though. I was doing the RowHeaderWidth as a datagrid property because there were a couple of other properties that are available to the datagrid object but not to the TableStyle (such as the BackGroundColor). Thanks for pushing me in the right direction. I would like to know though why the setting of the datagrid property changed to 15 during the execution of a line that set it to 5, but only on the second time through.

BuzMeg at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic Language...