logo
down
shadow

DevExpress Add items to ComboBox at run time


DevExpress Add items to ComboBox at run time

By : user2955957
Date : November 22 2020, 10:48 AM
I hope this helps . All DevExpress editors have the SomeEditor.Properties property which contains settings specific to the editors. So, you can get Items collection from comboBox.Properties.Items property:
code :
If combobox1.SelectectItem.ToString = "Item1" Then 
    Combobox2.Properties.Items.Add("Added Item String")
End If


Share : facebook icon twitter icon
Adding items to a ComboBox that is added to userform during run time

Adding items to a ComboBox that is added to userform during run time


By : muratalp tokmakci
Date : March 29 2020, 07:55 AM
seems to work fine I am trying to add a combo box to a user form which will be created at run time , the problem I am facing is to add items to the combo box? Not able to figure out where the mistake would be. . , Remove the word Designer
Try this (Tried And Tested)
code :
Set NewComboBox = TempForm.Controls.Add("Forms.ComboBox.1")
Option Explicit

Sub Sample()
    Dim TempForm As Object
    Dim Ret

    Set TempForm = ThisWorkbook.VBProject.VBComponents.Add(3)

    Ret = addComboBox(TempForm, "CBox", 1, "MyCombo", "1;2;3;4")

    VBA.UserForms.Add(TempForm.Name).Show
End Sub

Function addComboBox(ByRef TempForm As Object, ByVal controlType As String, _
ByVal pos As Integer, ByVal strCaption As String, ByVal strValues As String)

    Dim NewComboBox As MSForms.ComboBox
    Dim n As Long, nLines As Long, i As Long
    Dim arr As Variant

    Set NewComboBox = TempForm.designer.Controls.Add("Forms.ComboBox.1")
    arr = Split(strValues, ";")


    With NewComboBox
        .Name = strCaption & "_" & controlType & "_" & pos
        .Top = 20 + (12 * pos)
        .Left = 10
        .Width = 150
        .Height = 12
    End With

    n = 2

    With TempForm
        nLines = .CodeModule.CountOfLines
        .CodeModule.InsertLines nLines + 1, "Private Sub UserForm_Initialize()"
        For i = 0 To UBound(arr)
            .CodeModule.InsertLines nLines + n, "    " & _
            NewComboBox.Name & ".AddItem " & arr(i)
            n = n + 1
        Next i
        .CodeModule.InsertLines nLines + n, "End Sub"
    End With
End Function
Option Explicit

Sub Sample()
    Dim TempForm As Object
    Dim Ret

    Set TempForm = ThisWorkbook.VBProject.VBComponents.Add(3)

    Ret = addComboBox(TempForm, "CBox", 1, "MyCombo", "1;2;3;4")

    Ret = addComboBox(TempForm, "CBox1", 1, "MyCombo1", "5;6;7;8", 20)

    Ret = addComboBox(TempForm, "CBox2", 1, "MyCombo2", "9;10;11;12", 40)

    VBA.UserForms.Add(TempForm.Name).Show
End Sub

Function addComboBox(ByRef TempForm As Object, ByVal controlType As String, _
ByVal pos As Integer, ByVal strCaption As String, ByVal strValues As String, _
Optional s As Long)

    Dim NewComboBox As MSForms.ComboBox
    Dim n As Long, nLines As Long, i As Long, uInitLine As Long
    Dim arr As Variant
    Dim MyModule As Object

    Set NewComboBox = TempForm.Designer.Controls.Add("Forms.ComboBox.1")
    arr = Split(strValues, ";")

    With NewComboBox
        .Name = strCaption & "_" & controlType & "_" & pos
        .Top = 20 + (12 * pos) + s
        .Left = 10
        .Width = 150
        .Height = 12
    End With

    '~~> Connect to the code module of the Userform
    Set MyModule = ThisWorkbook.VBProject.VBComponents(TempForm.Name).CodeModule

    '~~> Check if there is a procedure called UserForm_Initialize
    On Error Resume Next
    uInitLine = MyModule.ProcStartLine("UserForm_Initialize", 0)
    On Error GoTo 0

    With TempForm
        '~~> UserForm_Initialize Found
        If uInitLine > 0 Then
            nLines = uInitLine + 2: n = 0
            For i = 0 To UBound(arr)
                .CodeModule.InsertLines nLines + n, "    " & _
                NewComboBox.Name & ".AddItem " & arr(i)
                n = n + 1
            Next i
        Else
            n = 2

            nLines = .CodeModule.CountOfLines

            .CodeModule.InsertLines nLines + 1, "Private Sub UserForm_Initialize()"
            For i = 0 To UBound(arr)
                .CodeModule.InsertLines nLines + n, "    " & _
                NewComboBox.Name & ".AddItem " & arr(i)
                n = n + 1
            Next i
            .CodeModule.InsertLines nLines + n, "End Sub"
        End If
    End With
End Function
Usercontrol contains a combobox, but the Items set at design time are not in the run time

Usercontrol contains a combobox, but the Items set at design time are not in the run time


By : Neeta Bisht
Date : March 29 2020, 07:55 AM
wish help you to fix your issue I have a user control that contains a textbox and a combobox. I have exposed the combobox's Item property to clients of the user control, thus: , You need an attribute:
code :
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ComboBox.ObjectCollection Item {
  get { return baseComboBox.Items; }
}
DevExpress: How to make a Devexpress Combo box shows only non selected items?

DevExpress: How to make a Devexpress Combo box shows only non selected items?


By : blumblex
Date : March 29 2020, 07:55 AM
I hope this helps you . You can filter data source of combo-box using LINQ. Remove earlier selected items from data source.When you add a new row, on callback of control you can filter out this data source.
Change DevExpress MVC ComboBox selected value based on another combobox value

Change DevExpress MVC ComboBox selected value based on another combobox value


By : user3226780
Date : March 29 2020, 07:55 AM
hop of those help? The main idea it to handle the client-side SelectedIndexChanged event of the (judge) ComboBox and update the related (county) ComboBox via a callback. Check out the related MVC ComboBox Extension - How to implement cascaded combo boxes guide to find all the necessary implementation details.
LabVIEW: How to dynamically create combobox items during run time

LabVIEW: How to dynamically create combobox items during run time


By : Rob Atkinson
Date : March 29 2020, 07:55 AM
Does that help Build an array of strings first and then write to the "Strings[]" property of the combo box using a reference or a property node.
Related Posts Related Posts :
  • how to refresh my datagridview after I add new data
  • How to get Motherboard name in VB.net?
  • Loop Through LINQ Results
  • How do I remove this GoTo?
  • Display image in DataGridView not working properly
  • How can limit how many times an operator shows up in my maths quiz in vb?
  • Expression Lambda to order fields with null value
  • GetManifestResourceStream in module
  • Save and open vbs script programmatically
  • Option Strict On, set Focus of unknown object type
  • Google API No application is associated with the specified file for this operation
  • Converting items in listview too string. VB
  • Mouse position at end of textbox on Mouse Click event
  • Run or Embed VB.NET console application within a VB.NET or C# forms application
  • Getting error while running the query
  • DevExpress GridView FocusedRowHandle Does not update on right click
  • Inserting combo box values?
  • Local RDLC report using spatial data
  • vb.net database query and checkbox , proper way to do?
  • Why error ???? Syntax error in INSERT INTO statement
  • string.IsNullOrEmpty vs string = '' in Visual Basic
  • Execute a subroutine before exiting the application
  • comparing two dates at midnight in vb never match
  • DataSource No Longer Fills Data Calls VB 2010
  • Check if todays is first weekday of month?
  • VB.NET - LINQ - dbContext - Where - Letter is not declared error. Trying to update single record
  • What is the equivalent of FirstSibling in .NET XMLNode?
  • Get value of one columns in DataGridView with multi select vb.net
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org