回复 6楼robert的帖子
由于我这边不能在上班期间上传下载文件,所以做了一个动态模板的Sample。
首先创建一个Form1,在Form1上拖一个Mr,Mr的Name定义为mlsREJI。
操作方法:首先把第一列的值从上到下修改成当前值+11(小键盘直接输入,不是通过下拉菜单选择),比如11变成22,然后通过鼠标点击选择下一行。
都改完了,会发现第一列和第二列的值不相等。
然后从上到下点击第一列的单元格,发现光标进入单元格的同时触发了SelectedIndexChanged事件,导致前一列和后一列的值相等了。
- Public Class Form1
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Dim tmplate As New GrapeCity.Win.MultiRow.Template
- tmplate.Clear()
- tmplate.Width = mlsREJI.Width
- tmplate.Row.Width = tmplate.Width
- tmplate.Row.Height = 21
- tmplate.Row.Cells.Add(New GrapeCity.Win.MultiRow.InputMan.GcComboBoxCell)
- tmplate.Row.Cells.Add(New GrapeCity.Win.MultiRow.LabelCell)
- tmplate.Row.Cells(1).Location = New Point(tmplate.Row.Cells(0).Size.Width, 0)
- CType(tmplate.Row.Cells(0), GrapeCity.Win.MultiRow.InputMan.GcComboBoxCell).DropDownStyle = GrapeCity.Win.MultiRow.MultiRowComboBoxStyle.DropDown
- With CType(tmplate.Row.Cells(0), GrapeCity.Win.MultiRow.InputMan.GcComboBoxCell).Items
- .Add("11")
- .Add("22")
- .Add("33")
- .Add("44")
- .Add("55")
- .Add("66")
- .Add("77")
- .Add("88")
- .Add("99")
- .Add("00")
- End With
- CType(tmplate.Row.Cells(0), GrapeCity.Win.MultiRow.InputMan.GcComboBoxCell).AutoSelect = False
- mlsREJI.Template = tmplate
- mlsREJI.AllowUserToAddRows = False
- mlsREJI.AllowUserToResize = False
- mlsREJI.AllowUserToDeleteRows = False
- mlsREJI.AllowUserToAutoFitColumns = False
- mlsREJI.RowCount = 10
- mlsREJI.EditMode = GrapeCity.Win.MultiRow.EditMode.EditOnEnter
- For inti As Integer = 0 To 6
- mlsREJI.Item(inti, 0).Value = CStr(inti + 1) & CStr(inti + 1)
- Next
- End Sub
- Private Sub mlsREJI_CellEditedFormattedValueChanged(sender As Object, e As GrapeCity.Win.MultiRow.CellEditedFormattedValueChangedEventArgs) Handles mlsREJI.CellEditedFormattedValueChanged
- Debug.Print(e.Reason)
- If e.Reason = "SelectedIndexChanged" Then
- mlsREJI(e.RowIndex, e.CellIndex + 1).Value = mlsREJI(e.RowIndex, e.CellIndex).EditedFormattedValue
- End If
- End Sub
- Private Sub GcMultiRow1_EditingControlShowing(sender As Object, e As GrapeCity.Win.MultiRow.EditingControlShowingEventArgs) Handles mlsREJI.EditingControlShowing
- If TypeOf e.Control Is GrapeCity.Win.MultiRow.InputMan.GcComboBoxEditingControl Then
- Dim combo As GrapeCity.Win.MultiRow.InputMan.GcComboBoxEditingControl = e.Control
- RemoveHandler combo.SelectedIndexChanged, AddressOf combo_SelectedIndexChanged
- AddHandler combo.SelectedIndexChanged, AddressOf combo_SelectedIndexChanged
- End If
- End Sub
- Private Sub combo_SelectedIndexChanged(sender As Object, e As EventArgs)
- With mlsREJI.CurrentCell
- Call mlsREJI_CellEditedFormattedValueChanged(mlsREJI, New GrapeCity.Win.MultiRow.CellEditedFormattedValueChangedEventArgs(.RowIndex, .CellIndex, .Name, "SelectedIndexChanged"))
- End With
- End Sub
- End Class
复制代码 |