我想在ApplyCellStyleToEditingControl子例程中设置AutoCompleteMode属性,或者如何在另一个类中使用类变量/属性 [英] I want to set the AutoCompleteMode property in ApplyCellStyleToEditingControl subroutine OR How to use a class variable/property in another class

查看:123
本文介绍了我想在ApplyCellStyleToEditingControl子例程中设置AutoCompleteMode属性,或者如何在另一个类中使用类变量/属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


<pre lang="x-vbnet">'I am creating a DataGridView Column. and it is working well. now 'I want to customise this column with AutoCompleteMode, and 'AutoCompleteSource properties to show the customised data. I 'made the properties for this columns, and these are also working 'well. but these properties are not working in the '"ApplyCellStyleToEditingControl" subroutine.
'
'Please help me to use these column properties in the '"ApplyCellStyleToEditingControl" subroutine.



  Public Class DataGridViewDataValueColumn
    Inherits DataGridViewColumn

    Dim m_AutoCompleteMode As AutoCompleteMode, _
      m_AutoCompleteSource As AutoCompleteSource, _
      m_AutoCompleteStringCollection As AutoCompleteStringCollection

    Public Sub New()
      MyBase.New(New DataValueCell())
    End Sub

    Public Overrides Property CellTemplate() As DataGridViewCell
      Get
        Return MyBase.CellTemplate
      End Get
      Set(ByVal value As DataGridViewCell)

        ' Ensure that the cell used for the template is a DataValueCell.
        If (value IsNot Nothing) AndAlso _
          Not value.GetType().IsAssignableFrom(GetType(DataValueCell)) _
          Then
          Throw New InvalidCastException("Must be a DataValueCell")
        End If
        MyBase.CellTemplate = value

      End Set
    End Property

#Region "User Defined Properties"

    '&*--------------------------------------*&'
    <Description("Indicates the text completion behaviour of the combo box."), DefaultValue(AutoCompleteMode.None)> _
    Public Property AutoCompleteMode() As AutoCompleteMode
      Get
        Return m_AutoCompleteMode
      End Get
      Set(ByVal value As AutoCompleteMode)
        m_AutoCompleteMode = value
      End Set
    End Property

    <Description("The source of complete strings used to automatic completion."), DefaultValue(AutoCompleteSource.None)> _
    Public Property AutoCompleteSource() As AutoCompleteSource
      Get
        Return m_AutoCompleteSource
      End Get
      Set(ByVal value As AutoCompleteSource)
        m_AutoCompleteSource = value
      End Set
    End Property

    <Description("The autocomplete custom source.")> _
    Public Property AutoCompleteCustomSource() As AutoCompleteStringCollection
      Get
        Return m_AutoCompleteStringCollection
      End Get
      Set(ByVal value As AutoCompleteStringCollection)
        m_AutoCompleteStringCollection = value
      End Set
    End Property

#End Region
  End Class

  '&*--------------------------------------*&'
  Class DataValueCell
    Inherits DataGridViewTextBoxCell

    Public Sub New()
      '
    End Sub

    Public Overrides ReadOnly Property EditType As Type
      Get
        Return GetType(PCLDataGridViewTextBoxEditingControl)
      End Get
    End Property

  End Class

  '&*--------------------------------------*&'
  '&* Edit DataGridView Columns      *&'
  '&*--------------------------------------*&'
  Class PCLDataGridViewTextBoxEditingControl
    Inherits DataGridViewTextBoxEditingControl

    Public Overrides Function EditingControlWantsInputKey(ByVal keyData As Keys, ByVal dataGridViewWantsInputKey As Boolean) As Boolean
      Select Case ((keyData And Keys.KeyCode))
        Case Keys.Prior, Keys.Next, Keys.End, Keys.Home, Keys.Left, Keys.Up, Keys.Right, Keys.Down, Keys.Delete
          Return True
      End Select
      Return MyBase.EditingControlWantsInputKey(keyData, dataGridViewWantsInputKey)
    End Function

    Public Overrides Sub ApplyCellStyleToEditingControl(ByVal dataGridViewCellStyle As DataGridViewCellStyle)
      With DirectCast(Me, TextBox)
        '.AutoCompleteMode = DataGridViewDataValueColumn.AutoCompleteMode_Value
        '.AutoCompleteSource = DataGridViewDataValueColumn.AutoCompleteSource_Value
        '.AutoCompleteCustomSource = MyBase.AutoCompleteCustomSource
      End With
    End Sub

  End Class

推荐答案

您好,Ranjan,

  跨度>

谢谢您的发帖!  ;我建议您在一个MS论坛中发布您的问题,

Thank you for your post!  I would suggest posting your question in one of the MS Forum,

Windows开发人员中心 > Windows窗体论坛 > Windows窗体数据控件和数据绑定
Windows Developer Center > Windows Forms Forums > Windows Forms Data Controls and Databinding


这篇关于我想在ApplyCellStyleToEditingControl子例程中设置AutoCompleteMode属性,或者如何在另一个类中使用类变量/属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆