Tuesday, December 22, 2009

How to add CheckedListBox Items Programmatically in windows application?

C#
         ArrayList US = new ArrayList();
            US.Add(new country("India", "Ind"));
            US.Add(new country("Austria", "Ans"));
            US.Add(new country("Malaysia", "Mal"));

            checkedListBox1.DataSource = US;
            checkedListBox1.DisplayMember = "County";
            checkedListBox1.ValueMember = "SCode";

   public class country
        {
            private string Contry;
            private string code;

            public country(string strLongName, string strShortName)
            {

                this.Contry = strShortName;
                this.code = strLongName;
            }

            public string SCode
            {
                get
                {
                    return Contry;
                }
            }

            public string County
            {

                get
                {
                    return code;
                }
            }

        }
 String str=checkedListBox1.SelectedValue.ToString();

No comments:

Post a Comment