Why does my datagrid width got narrower in run time?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I set the Locked property = True for the datagrid but in run time the width
shriks automatically making the windows looking messy. How do I fix this so
it would stay the same as in the designer sheet?
Thanks, Alpha
 
I set the GridColumn style for each of the column=100 but after I run the
application it's set back to the original 75. I do this in the designer
window's property area. Do I need to add code to set the column width at
loading time for it to work?

Thanks, Alpha
 
Thank you, that is an informative web site. However, I'm still not sure
where to set the column width. The example uses a click button event. I
just want the grid to come up at the size I specified. I put this in the
designer grid property and also at the loadup time and it still not working.
Thanks, Alpha
 
You need to read about adding DataGridColumnStyles to your grid. With these,
you can specify a specific width for the columns.

Basically, you want to create a DataGridTableStyle, add DataGridColumnStyle
derived objects for each column (either DataGridBoolColumn or
DataGridTextBoxColumn, or one of your own custom DataGridColumnStyle derived
objects). Set the HeaderText and MappingName of the styles and then set the
width. Don't forget to set the MappingName property of the table style as
well.

Then add this DataGridTableStyle to the TableStyles collection of the grid.

Good luck.

Pete
 
Back
Top