none
Custom Control Property With Drop Down options from database RRS feed

  • Question

  • I am seeking a method of creating a new property on a custom control that on load would populate the dropdown list options for this property from a database at design time.

    Any thoughts of how this can be done?

    Tuesday, November 27, 2018 10:20 PM

All replies

  • Hi,

    If you have already got the data from the database dt

    Class CustomDataBaseTypeEditor Inherits UITypeEditor Public Overrides Function GetEditStyle(ByVal context As System.ComponentModel.ITypeDescriptorContext) As UITypeEditorEditStyle Return UITypeEditorEditStyle.DropDown End Function Public Overrides Function EditValue(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal provider As IServiceProvider, ByVal value As Object) As Object Dim edSvc As IWindowsFormsEditorService = CType(provider.GetService(GetType(IWindowsFormsEditorService)), IWindowsFormsEditorService) If edSvc IsNot Nothing Then Dim cb As ComboBox = New ComboBox() cb.Datasource=dt

    dt.DisplatMumber="XXX1"

    dt.ValueMumber="XXX2" Return cb.SelectedValue End If Return value End Function End Class

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 29, 2018 2:04 AM