正式使用这个控件界面:UI
使用代码:
Private WithEvents CmbBoxMaterialList As ControlLib.NeMoCmbBox = New ControlLib.NeMoCmbBox() Private Sub IniCmbListView() Me.CmbBoxMaterialList.Table = (New EvaMaterialClass).GetTableCN() Me.CmbBoxMaterialList.DisplayMember = "布料名称" Me.CmbBoxMaterialList.ValueMember = "布料名称" Me.CmbBoxMaterialList.LvWidth = 450 Me.CmbBoxMaterialList.LvHeight = 200 Me.CmbBoxMaterialList.Visible = False Me.DvMaterial.Controls.Add(CmbBoxMaterialList) End Sub Private Sub DvMaterial_CellClick(ByVal sender As Object,ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DvMaterial.CellClick '在第一行显示comBox If Me.DvMaterial.CurrentCell.ColumnIndex = 1 Then '确定位置,显示comBox Dim rect As Rectangle = Me.DvMaterial.GetCellDisplayRectangle(Me.DvMaterial.CurrentCell.ColumnIndex,Me.DvMaterial.CurrentCell.RowIndex,False) CmbBoxMaterialList.Left = rect.Left CmbBoxMaterialList.Top = rect.Top CmbBoxMaterialList.Width = rect.Width CmbBoxMaterialList.Height = rect.Height CmbBoxMaterialList.Visible = True Else CmbBoxMaterialList.Visible = False End If End Sub Private Sub CmbBoxMaterialList_AfterRowSelectEvent(ByVal sender As Object,ByVal e As ControlLib.SelectEventArgs) Handles CmbBoxMaterialList.AfterRowSelectEvent ''处理选择后的数据。把CombBoxListView里面的数据用到DataGridView里面。 Me.DvMaterial.CurrentCell.Value = CmbBoxMaterialList.Text Me.DvMaterial.Rows(Me.DvMaterial.CurrentRow.Index).Cells(5).Value = CmbBoxMaterialList.SelectedRow(2) 'Me.Text = String.Format("SelectedItemIndex:{0}",CmbBoxMaterialList.SelectedItemIndex) End Sub