Hi ,
I have 30 columns in grid.
When i right click on the particular column header , pops up menu with freeze and unfreeze menu items.
If i click on the freeze menu item , it should freeze till that column .
If i right clcik on the 10 th column and click on freeze , it should freeze 1- 10 column s
If i right click and click on unfreeze gris should be normal .
Any help.
Thanks.
Hi,
What part of this are you having trouble with? There is no built-in functionality in the grid to do this with a context menu or to freeze multiple columns at once with the grid's UI.
But you could easily create your own context menu for this.
You will need to set UseFixedHeaders on the grid's DisplayLayout to true to enable fixed header. You have to be using RowLayoutStyle = None, fixed headers are not supported in RowLayout mode.
Here's an article that will help you detect which column was right-clicked.
HOWTO:UltraWinGrid Mouse Position and Column Identification
To fix a column, you simply set column.Header.Fixed to true.
I right clciked on 5 th column and I got the right clicked column index =5
Where should I use the line of code to freeze the columns from (1 to 5 columns).
Should I use below line of code only for 5 th column or to the all 5 columns(that upto right clicked column from 1 to 5)
headers.fixed =true
Where should I place this code exactly ,
You cannot do this with a single line of code. If you want to fix more than one column, you need to set the Fixed property on the header of each of the columns you want to fix.
Ishnant said:Where should I use the line of code to freeze the columns from (1 to 5 columns).
I don't understand what you mean by this. You should put the code wherever you want to fix the columns. If you are doing this in a right-click menu, then the code would go in the click event of your menu item.
If you want to fix the first 5 columns in the grid, then you need to loop through those columns and fix each one.
If fixing a column is not moving that columns to the left edge of the grid, then you are either using RowLayouts (RowLayoutStyle) or you did not set UseFixHeaders to true on the grid's DisplayLayout to enable fixed headers.
I did set the Usefixedheaders =true in intilizerlayout.
But on right click of menu how do i get teh access to .column to set the
.Header.Fixed =True for each column that I want to freeze.
Thanks,
That's a bit tricky. You have to use UIElements to do it. I have attached a small sample project here that I think does what you want.
Thank you so much .
I will try this and let you know.