My gridview columns are generated from SQL query like select * from table;
Any way I can disable the headers/ make them unclickable preventing user think he can sort by clicking them.
The header row should not be clickable by default. Can you show your gridview markup?
Never mind I have sorting set to true. Thats why I see clickable
Set AllowSorting to false.
hi sushsudh ,
From what I understand that you want to disable the headers and make them unclickable.
I would suggest you to follow the workground:
To cancel sorting, set off the GridColumn.OptionsColumn.AllowSort property. Also, you can cancel filtering in the GridColumn's OptionsFilter.
You can do it at run-time as shown below:
using DevExpress.XtraGrid.Columns;
private void DisableColumnHeaders()
{
foreach (GridColumn column in this.gridView1.Columns)
{
column.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False;
column.OptionsFilter.AllowAutoFilter = false;
column.OptionsFilter.AllowFilter = false;
}
}
And the last step: you can disable column header hottracking. Handle the GridView's CustomDrawColumnHeader event:
private void gridView1_CustomDrawColumnHeader(object sender, DevExpress.XtraGrid.Views.Grid.ColumnHeaderCustomDrawEventArgs e)
{
e.Info.State = DevExpress.Utils.Drawing.ObjectState.Normal;
}
Please let me know if this solution meets your requirements.
沒有留言:
張貼留言