I have a gridvie which i sho in two modes some columns change visibility
"colFirstSeen"].IsVisible = true;
"colTrust"].IsVisible = true;
radGridView1.Columns["colAcknowledged"].IsVisible = true;;
"colFirstSeen"].IsVisible = false
radGridView1.Columns["colFirstSeen"].VisibleInColumnChooser = false
radGridView1.Columns["colTrust"].IsVisible = false
"colAcknowledged"].IsVisible = false
When I change the value of local from true to false and than back to true the column "colFirstSeen", which is last is moving to the right
The image is attached.
Sorry, when I save the poste it changes the fomat.
5 Answers, 1 is accepted
from the information that you've provided, may i ask which AutoSizeColumnsMode you are using? I.e.
If you are using None then are you performing BestFitColumns as this will cause columns to move to allow them to resize for the content.
.radGridView1.MasterTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
I don't know what BestColumnFit does and if we are using it.
From the information that you have provided it's not possible to draw a conclusion. If you are able to replicate this in a simple test project, then please post that here so I can review it for you and I'll be happy to help
A few things before i offer some alternatives.
First of, i don't really like the BestFitColumns(), lately it is becoming very unstable
[Just open any grid and right click on the header and select best fit, do it again and again, and you will see that the column size keeps changing... kinnda strange considering it should be best fit, but maybe this is just me].
So, getting back to the problem at hand, the first alternative would be to just calculate the minimum size required for the column in order for it to display all the data inside that column. In this other thread i have provided some options to calculate the best possible widths of a column (or all the columns). A solution, this time for your exact case could go something like this:
Please test it and tell me if this suits your needs.
If you have any other questions i would be more than happy to assist in any way that i can.
Telerik WinForms MVP
Or you can use a cleaner version that uses custom properties for the column to store the old width of the column before hiding and restoring the column to that old width when making it visible again, like the following:
I have provided two different approaches here, the first and the active one here just takes the width of the required column and restores it when making it visible again, the second approach takes the width of all the columns, and restores all of them when making that column visible.
I believe that with this info you will be able to develop a solution that best fit your specific need.
Hope this helps, if you have any other questions or comments, please let me know,
Telerik WinForms MVP