DataGridViewComboBoxDisplayStyle.ComboBox Blue Boarder

时间:2017-12-01 17:08:08

标签: .net vb.net

这是微不足道的,但它伤害了我的强迫症。有没有办法删除添加到DataGridView的ComboBox的蓝色边框?

enter image description here

    Dim cmb As New DataGridViewComboBoxColumn()
    cmb.HeaderText = "Project"
    cmb.Name = "cmbProject"
    cmb.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox
    cmb.DisplayStyleForCurrentCellOnly = False
    cmb.Items.Add("0001")
    DGV.Columns.Add(cmb)

编辑:与这个问题无关,但我会在这里添加它,以防它帮助任何人。此代码在第一次单击时下拉ComboBox

    Private Sub dataGridView1_EditingControlShowing(ByVal sender As Object, ByVal e As DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
    Dim combo As ComboBox = CType(e.Control, ComboBox)
    If (combo IsNot Nothing) Then
        ' Remove an existing event-handler, if present, to avoid adding multiple handlers when the editing control is reused.
        RemoveHandler combo.Enter, New EventHandler(AddressOf ComboBox_Enter)
        ' Add the event handler. 
        AddHandler combo.Enter, New EventHandler(AddressOf ComboBox_Enter)
    End If
End Sub

Private Sub ComboBox_Enter(ByVal sender As Object, ByVal e As EventArgs)
    TryCast(sender, ComboBox).DroppedDown = True
End Sub

0 个答案:

没有答案