玩转DevExpress.XtraGrid.view.gridview

玩转DevExpress.XtraGrid.view.gridview  


(一)双击展开,收缩字表
Private Sub ExpandedChild(ByVal sender As DevExpress.XtraGrid.Views.Grid.GridView)
'
找出焦点行
Dim VIntPage As Integer = sender.FocusedRowHandle
If sender.GetMasterRowExpanded(VIntPage) Then
sender.CollapseMasterRow(VIntPage)
Else
sender.ExpandMasterRow(VIntPage)
End If
End Sub

(二)单击选中某行的checkbox
Private Sub GridChecked(ByVal sender As DevExpress.XtraGrid.Views.Grid.GridView, ByVal TableIndex As Integer)
Try
'
找出焦点行做在的内存表中所在的行
Dim rowPlace As DataRow = CType(sender, GridView).GetDataRow(CType(sender, GridView).FocusedRowHandle)
'SELECTED
checkbox的字段名(1:选中,0:不选中)
If rowPlace("SELECTED") = 1 Then
rowPlace("SELECTED") = 0
Else
For Each VRow As DataRow In objLowerPriceQueryOut.Info.Tables(TableIndex).Rows
VRow!SELECTED = 0
Next
rowPlace("SELECTED") = 1
End If
Catch ex As Exception
End Try
End Sub

(三)设置gridview只读属性options->optionsbehavior->editablefalse
设置单击选中该列,而不是单元格options->optionsSelction
->EnableApperanceFocusedCell
false

(四)将gridview中某一字段设置为RepositoryItemHyperLinkEdit,要触发该链接的事件,可以在In_place Editor Repository中触发click 事件。但是,触发该事件的同时,gridview中的OptionBehavior->Editable必须设置为true

(五)在gridview中绑定内存表,要改变焦点行某一字段的值
'
根据gridview的焦点行获取内存表的行数
Dim rowGoMain As DataRow = gridview.GetDataRow(sender.FocusedRowHandle)
'
修改该行的值
rowGoMain("
字段名") = "aa"

(六)对DataSet进行查询:
ds.Tables[0].DefaultView.RowFilter = "
查询条件";

(七) 设置展开第一行的字表
gridview.SetMasterRowExpanded(1, True)

(八)设置gridview某一列汇总:选中该列,在SummaryItem设置相应属性即可。DisplayFormat为显示的格式,FieldName为需要汇总的字段……

(九)设置gridview单元格自动换行:在单元格中一个Memo控件,columnedit->new->MemoEdit,gridview中设置optionsview->rowautoheight=true

你可能感兴趣的:(C#)