对于Grid是我们在程序中最常用到的麻烦控件,他有很强大的功能,有时候为了一个小小属性就能实现的功能,可能你要研究半天,我就是这样。现在来总结一下可能会经常使用到的功能。
1。动态加载button,checkbox,dropdrow等控件。
ultraGrid1.DisplayLayout.Bands[
0
].Columns[
"
button
"
].Style
=
Infragistics.Win.UltraWinGrid.ColumnStyle.Button;
ColumnStyle是列样式,它是个枚举类型,里面是各种常用的类型,TriStateCheckBox.,Edit,Button,.Edit.DropDownValidate,.DropDownList,.DropDownCalendar,.DropDown.,CheckBox.Button.。
添加button后,他的响应事件是ClickCellButton。
2。使某一列不能编辑。同上Antivatian也是枚举类型。
ultraGrid1.DisplayLayout.Bands[
0
].Columns[
"
id
"
].CellActivation
=
Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
3。使某一单元格不能编辑
ultraGrid1.Rows[
0
].Cells[
1
].Activation
=
Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
4。获取点击或选中某一行的索引,并得到其中某一值
int
i
=
this
.ultraGrid1.ActiveRow.Index;
string id = this .ultraGrid1.Rows[i].Cells[ 0 ].Value.ToString().Trim();
string id = this .ultraGrid1.Rows[i].Cells[ 0 ].Value.ToString().Trim();
5加载ColumnStyle没有的控件,如:progressbar等
ultraGrid1.DisplayLayout.Bands[
0
].Columns[
"
progressbar
"
].EditorControl
=
new
Infragistics.Win.UltraWinProgressBar.UltraProgressBar();