Datagrid Column resize

J

Jorge

Hello All
I am trying to preserve the width of column in a datagrid
made by the user.

On form load i use this
<code>
Me.DataGrid2.TableStyles("artenc").GridColumnStyles
(0).Width = 30
Me.DataGrid2.TableStyles("artenc").GridColumnStyles
(1).Width = 30
Me.DataGrid2.TableStyles("artenc").GridColumnStyles
(2).Width = 30
</code>
the user then resizes manually the width any columns .
Them after i update the datagrid dataset i want try to
store the current width
<code>
Dim tableStyle As DataGridTableStyle
tableStyle = New DataGridTableStyle
tableStyle.MappingName = "artenc"
Me.DataGrid2.TableStyles.Clear()
Me.DataGrid2.TableStyles.Add(tableStyle)

WidthDatagrid2(0) = Me.DataGrid2.TableStyles
("artenc").GridColumnStyles(0).Width
WidthDatagrid2(1) = Me.DataGrid2.TableStyles
("artenc").GridColumnStyles(1).Width
WidthDatagrid2(2) = Me.DataGrid2.TableStyles
("artenc").GridColumnStyles(2).Width

Console.WriteLine(Me.DataGrid2.TableStyles
("artenc").GridColumnStyles(1).Width)
Console.WriteLine(Me.DataGrid2.TableStyles
("artenc").GridColumnStyles(1).Width)
Console.WriteLine(Me.DataGrid2.TableStyles
("artenc").GridColumnStyles(2).Width)
Console.WriteLine(WidthDatagrid2(0))
Console.WriteLine(WidthDatagrid2(1))
Console.WriteLine(WidthDatagrid2(2))
</code>
all the console display 75 and i sure the width is not
75!?

Any suggestion on how to store the width of datagrid's
column?

Thanks

Kind Regards
Jorge
 
B

BobAchgill

Jorge,

Did you get this resolved? I could not find the thread
on your discussion to see if anyone answered.

I am interested because I have the same need... both to
set column width and preserve user's changing column
width on datagrids.

Thanks!

Bob Achgill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top