You must Sign In to post a response.
  • Category: .NET

    Splitting Strings and Add into combo box in

    Dear All,

    i have a string 'April,May,June'.
    I need to split this string by separated and added into Combo Box using

    when i select anyone value in Name of Quarter Combobox, the Name of Month Combobox have to load this by adding separately 1. April
    2. May
    3. June.

    is it possible ?

    Ramkumar G.R
  • #749164
    You can write the code as below

    string strMonth = "April,May,June";

    string[] strMonthArray = strMonth.Split(',');

    for(int i=0; I< strMonthArray.Length;i++ )

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #749165
    You can split string by "," and than use for loop to insert value in combobox.
    I have created snippet for you take a look.

    Dim Data As String = "April,May,June'"

    Dim i As Integer
    For i = 0 To Data.Split(",").Count()- 1 Step i + 1
    Dim MonthName As String = Data.Split(",")(i).ToString()

    checkedListBox1.Items.Add(i + 1,MonthName))

    check aboove code i have convert it from c# code which i have created so may be some syntax error in it, update it and use it.

    C# code

    string Data = "April,May,June'";
    for (int i = 0; i < Data.Split(',').Count(); i++)
    string MonthName = Data.Split(',')[i].ToString();

    checkedListBox1.Items.Add(i + 1,MonthName));


    Nirav Prabtani (Senior Web Developer)
    Email :
    blog :

  • #749170
    You Can use following Code

    Dim s As String = "Jan,fab,March"
    Dim lst As New List(Of String)
    lst = s.Split(",").ToList()
    ComboBox1.DataSource = lst

    Umesh Bhosale

  • #749181

    Try something like below

    string result="jan,feb,march";
    String[] param = result.Split(',');
    foreach(string str in param)

    Try something like above to achieve your goal....

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • Sign In to post your comments