We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Datagrid Column widths

I have two datagrids that have related information. When I resize a column in one grid, I want to set the size of the corresponding column in the other datagrid to be the size of the resized column. This is where my problem starts. I have used a datagrid.HitTest(e.X, e.Y) in a mouse down event to see if it is a column resize event and then if it is to see which column has been resized. In the mouse down event I get the width of the resized column using: hti = dgClientWIP.HitTest(e.X, e.Y) x = hti.column datagrid.TableStyles(0).GridColumnStyles(x).Width When I drag the column to the new size and let the mouse up, I display the width of the column again. The size is the same as before I resized the column. It only seems to update the new column width after the mouseup event has completed. I cannot work out how to get the new value for the column width from any event that fires – I could set a timer to check to see if there has been a column resize event but that seems rather tacky code. Any ideas gratefully received. With thanks Graham Jones

2 Replies

JO john May 11, 2004 08:21 AM UTC

I believe there is a WidthChanged event which you can subscribe to on the DataGridColumnStyle class. Cheers!


GJ Graham Jones May 17, 2004 05:11 AM UTC

Many thanks, that did the job nicely. Regards Gj

Loader.
Up arrow icon