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.
Unfortunately, activation email could not send to your email. Please try again.

column widths and hidden columns

Thread ID:

Created:

Updated:

Platform:

Replies:

16751 Jul 23,2004 05:23 AM Dec 17,2004 07:58 AM Windows Forms 7
loading
Tags: GridControl
Scott Lundgren
Asked On July 23, 2004 05:23 AM

I have a need to allow the user to selectively show/hide columns and change their widths in a databound grid. To do this, I have created a dialog which enumerates all columns and displays their "hidden" and "width" values as such: _DataGrid.Model.Cols.Hidden(i) _DataGrid.Model.ColWidths(i) On application of the new settings, I set the hidden and width parameters as such: _DataGrid.Model.ColWidths(i) = nSomeInt _DataGrid.Model.Cols.Hidden(i) = fSomeBoolean where nSomeInt is a value > 0. However, when the changes take effect, the width of the now hidden columns, no matter the previous value, is set to zero. To restate: The behavior I am seeing is is that the following single line: _DataGrid.Model.Cols.Hidden(nSomeIndex) = true results not only in the hidden value changing, but also the corresponding column width being set to 0. I can see this with the debugger. I have added a collection of GridBoundColumns to my grid for further formatting control of each column. I have noticed that the problem above does not occur in grids without GridBoundColumns. Scott

Administrator [Syncfusion]
Replied On July 23, 2004 05:38 AM

What if you switch the order of the two lines to _DataGrid.Model.Cols.Hidden(i) = fSomeBoolean _DataGrid.Model.ColWidths(i) = nSomeInt Does that let the colwidths retain the values you are setting, and still keep the columns hidden if they were set to be hidden?

Scott Lundgren
Replied On July 23, 2004 05:52 AM

Clay, Thanks for the suggestion - however, I''ve tried already and tried again, and it does not solve the problem. The behavior that I am seeing is that the second line (setting the column width) has no effect on the value of the column width. This is verified using the debugger. Scott > >_DataGrid.Model.Cols.Hidden(i) = fSomeBoolean >_DataGrid.Model.ColWidths(i) = nSomeInt >

Scott Lundgren
Replied On July 23, 2004 05:59 AM

Also, I should make something clear: When the column is made visible again: .Model.Cols.Hidden(i) = false the width is restored, to the correct value. My problem is that, for the purposes of custom serialization, I''d like to be able to get at the "if I was visible, what width would I be" value, short of showing the column, getting the width, and hiding it again. > >Clay, > >Thanks for the suggestion - however, I''ve tried already and tried again, and it does not solve the problem. > >The behavior that I am seeing is that the second line (setting the column width) has no effect on the value of the column width. This is verified using the debugger. > >Scott > >> >>_DataGrid.Model.Cols.Hidden(i) = fSomeBoolean >>_DataGrid.Model.ColWidths(i) = nSomeInt >>

Administrator [Syncfusion]
Replied On July 23, 2004 07:28 AM

Digging through our source shows the grid.Model.ColWidths indexer explicitly returning zero if the the column is hidden. So, this behavior is by design. The code also shows that you should be able to get the size of a hidden column if you directly call grid.Model.ColWidths.GetSize instead of going through the indexer. Hopefully this will let you do what you need to do.

Scott Lundgren
Replied On July 23, 2004 07:34 AM

Thanks Clay - that is what I was looking for. Scott

Shankar Ramasubramanian
Replied On December 17, 2004 07:26 AM

The Getsize return -1. I''m using 2.0.5.0. I read in one of the postings that getsize return -1 if it''s a default value. So, How to get the hidden column width > >I have a need to allow the user to selectively show/hide columns and change their widths in a databound grid. To do this, I have created a dialog which enumerates all columns and displays their "hidden" and "width" values as such: > >_DataGrid.Model.Cols.Hidden(i) >_DataGrid.Model.ColWidths(i) > >On application of the new settings, I set the hidden and width parameters as such: > >_DataGrid.Model.ColWidths(i) = nSomeInt >_DataGrid.Model.Cols.Hidden(i) = fSomeBoolean > >where nSomeInt is a value > 0. However, when the changes take effect, the width of the now hidden columns, no matter the previous value, is set to zero. > >To restate: The behavior I am seeing is is that the following single line: > > _DataGrid.Model.Cols.Hidden(nSomeIndex) = true > >results not only in the hidden value changing, but also the corresponding column width being set to 0. I can see this with the debugger. > >I have added a collection of GridBoundColumns to my grid for further formatting control of each column. I have noticed that the problem above does not occur in grids without GridBoundColumns. > >Scott

Administrator [Syncfusion]
Replied On December 17, 2004 07:58 AM

When it is -1 then you can get the default width from Model.Cols.DefaultSize. Stefan

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;