问题
I have an Infragistics grid and I want to disable and enable some columns based upon some requirement. I have read some articles that say to use AllowUpdate = DefaultableBoolean.True
but it did not work for me.
回答1:
I suppose that when you talk of disabled columns you mean disable editing in these columns. Also you don't specify the language, so I will use C#
UltraGridColumn c = grdWork.DisplayLayout.Bands[0].Columns["YourColumnName"];
c.CellActivation = Activation.NoEdit;
c.CellClickAction = CellClickAction.CellSelect;
The property CellActivation could also be set to Activation.Disabled
or Activation.ActivateOnly
.
The property CellClickAction allows to set an appropriate selection status for the cell clicked. You could use CellSelect
or RowSelect
. (This last one, to mimic the behavior of a ListBox)
As usual, the real difficulty is to find the correct property. Then Intellisense will give you a quick and fair explanation of the meaning of these values.
回答2:
If you just want to show and hide the columns as needed then you can try the following.
UltraGrid myGrid = new UltraGrid();
//Bind to your data here
myGrid.DisplayLayout.Bands[0].Columns["ColumnName"].Hidden = true;
来源:https://stackoverflow.com/questions/11802054/enabling-and-disabling-of-columns-in-infragistics-ultragrid