Allowing user to change the width of a datagrid column

  • Thread starter Thread starter zsource
  • Start date Start date
Z

zsource

I have an Datagrid that displays a number of columns of
data. I want to allow the user to change the width of
each of the columns as they need to. When the
application runs, the user can modify the width, but
after all the events have fired and the grid is presented
back to the user, the column is still presented back with
its original width. Am I missing something or am I
somehow overriding the user's column width change????
 
Could you sent me your source and I can take a look for you?

Thanks,

David

This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
| Content-Class: urn:content-classes:message
| From: "zsource" <[email protected]>
| Sender: "zsource" <[email protected]>
| Subject: Allowing user to change the width of a datagrid column
| Date: Sat, 9 Aug 2003 18:48:16 -0700
| Lines: 9
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcNe4XfPMBt2ozupRg6S26ovmrK2Nw==
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:30564
| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| I have an Datagrid that displays a number of columns of
| data. I want to allow the user to change the width of
| each of the columns as they need to. When the
| application runs, the user can modify the width, but
| after all the events have fired and the grid is presented
| back to the user, the column is still presented back with
| its original width. Am I missing something or am I
| somehow overriding the user's column width change????
|
|
 
This is actually a bug in DataGrid which causes this when there an event
handler associated with DataGrid.Click, using DataGrid.MouseUp to perform
the DataGrid.Click event handler functionality and remove the
DataGrid.Click event handler should fix it.

David
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Upon further investigation, it turns out that in the DataGrid.Click event
handler, ther is code which it sets the DataView's Sort property. This
internally sends a ListChanged event of type ListChangedType.Reset to the
datagrid thus forces the datagrid to reload the entire contents of the
datasource including resetting all of the columns. When the columns are
reset, the datagrid turns off the active column resizing logic to prevent
unexpected behavior. When the MouseUp event is used instead of the Click
event, the resize handling code has completed its action and the reset of
the columns has no effect on the previously completed column resize.

In summary, if you want to keep your resize working with all the DataGrid
column sorting and inplace editing, use MouseUp event to do all the work.

Thanks,

David

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top