This is a migrated thread and some comments may be shown as answers.

Width problem using Column chooser

7 Answers 164 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jan Hesselgren
Top achievements
Rank 1
Jan Hesselgren asked on 23 May 2008, 12:36 PM
Hello, I am using the latest version of the RadControls for Winforms, but I have a problem with the Column chooser function in RadGridView. When i drag in a new column, it's width is so small that I can't even grab it with the cursor to expand it. If I add more columns they also get small but I can grab them.

I have tried both with AutoSizeColumnsMode = "None" and "Fill".

My first idea was to subscribe to a column chooser event and resize the columns programmatically, but I couldn't find such event.

These are the properties of my RadGridView:

this.radGridViewLicenses.Dock = System.Windows.Forms.DockStyle.Fill;
            this.radGridViewLicenses.Location = new System.Drawing.Point(0, 0);
            this.radGridViewLicenses.Margin = new System.Windows.Forms.Padding(0);
            this.radGridViewLicenses.MasterGridViewTemplate.AllowAddNewRow = false;
            this.radGridViewLicenses.MasterGridViewTemplate.AllowDeleteRow = false;
            this.radGridViewLicenses.MasterGridViewTemplate.AllowEditRow = false;
            this.radGridViewLicenses.MasterGridViewTemplate.EnableFiltering = true;
            this.radGridViewLicenses.MasterGridViewTemplate.EnableGrouping = false;
            this.radGridViewLicenses.MasterGridViewTemplate.ShowRowHeaderColumn = false;
            this.radGridViewLicenses.Name = "radGridViewLicenses";
            this.radGridViewLicenses.ShowGroupPanel = false;
            this.radGridViewLicenses.Size = new System.Drawing.Size(390, 543);
            this.radGridViewLicenses.TabIndex = 0;
            this.radGridViewLicenses.ThemeName = "Telerik";

Any help is appreciated,

 - Joel

7 Answers, 1 is accepted

Sort by
0
Jan Hesselgren
Top achievements
Rank 1
answered on 24 May 2008, 07:35 AM
Some more information that could be useful:

Bound to my gridview is a List<> of custom objects with properties.
Some of the columns are not shown from the start, as I have set [Browsable(false)] on them...
0
Kiril
Telerik team
answered on 26 May 2008, 07:37 AM
Hello Jan Hesselgren,

Thank you for writing.

I created my own custom object with two string and an int column. I set the int column [Browsable(false)], initialized a list containing five objects  and bound it to the RadGridView. I then opened the column chooser, and dragged a column in it. However, I could easily drag the column back back to the grid area - I did not observe the behavior you reported.

I'm very interested in investigating further the issue you're describing. Please send me a small project that reproduces this behavior. It will help us address any potential issue faster.

I'm looking forward to your response.

Kind regards,
Kiril
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jan Hesselgren
Top achievements
Rank 1
answered on 27 May 2008, 01:23 PM
Hello again, I managed to solve the problem while trying to reproduce it.

There seems to be a bug with the MasterGridViewTemplate.BestFitColumns-Method. It sets the width to "5" for all invisible columns, which get's messy once the columns get visible again. I use the following workaround to solve the problem

rgv.MasterGridViewTemplate.BestFitColumns();  
foreach (GridViewColumn column in rgv.Columns)  
            {  
                if (!(column.IsVisible))  
                   column.Width = 100;  
            } 
0
Kiril
Telerik team
answered on 27 May 2008, 04:13 PM
Hi Jan Hesselgren,

Thank you for taking the time to write us.

I was able to reproduce the behavior you described. It is due to the fact that you most probably have the AutoSizeColumnsMode property of the ViewTemplate set to Fill. In this mode, the width values of all columns are set so as to have the sum of all these values equal the total width of the control. When you increase the width of a column, it comes only at the expense of the width of another column.

In this case, it is unclear what should should be the width of a column that was previously invisible. The minimum width of a column is 5 pixels, and this is why the column width is set to this value.

This is the rationale behind the behavior you're observing. Now, to achieve the desired functionality, you have two options:

  • Set the AutoSizeColumnsMode to None. Invoking the BestFit operation, will cause a column to be sized to the width it requires without the restictions imposed by the sum of width as is the case when the AutoSizeColumnsMode is Fill.
  • Set the width of the column manually, even though the AutoSizeColumnsMode is Fill. This is the approach you've currently chosen.
Thank you for bringing this point to our attention. We appreciate your involvement, and commitment to our product.

I hope this adds some clarity on why the RadGridView behaves the way it does. If you have any additional questions, please contact me. Your Telerik points have been updated.

All the best,
Kiril
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jan Hesselgren
Top achievements
Rank 1
answered on 28 May 2008, 07:10 AM
Hello again, and thanks for your quick response.

I have AutoSizeColumnsMode=None, so I am not sure why this problem arises.

I could send you a small project with this behaviour, how can I send it?

Thanks

0
Accepted
Kiril
Telerik team
answered on 28 May 2008, 07:59 AM
Hi Jan Hesselgren,

Thank you for getting back to me.

The columns do not keep track of whether they should set their own width according to the best-fit logic. You have two options:

  • Call BestFitColumns on the ViewTemplate level, after you make the previously invisible columns visible.
  • Call the BestFit method for all columns that were previously invisible, but only after you have made them visible.
The second approach is preferable, as it will not cause any unnecessary computations for the visible columns that have already been processed in this way.

If the issue still persists, after you implement one of the two approaches, please open a support ticket to be able to attach a file.

Greetings,
Kiril
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jan Hesselgren
Top achievements
Rank 1
answered on 28 May 2008, 08:23 AM
Thanks again for your support, both approaches seem to work well.
Tags
GridView
Asked by
Jan Hesselgren
Top achievements
Rank 1
Answers by
Jan Hesselgren
Top achievements
Rank 1
Kiril
Telerik team
Share this question
or