3
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by bhagawatshinde
0
private void CheckBoxListTest_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("name");
            for (int j = 0; j < 20; j++)
            {
                dt.Rows.Add("checkbox" + j.ToString());
            }

            CheckBox[] cks = new CheckBox[dt.Rows.Count];
            for (int j = 0; j < dt.Rows.Count; j++)
            {
                cks[j] = new CheckBox();
                cks[j].Text = "";
                cks[j].Checked = true;
              cks[j].Enabled = false;
                cks[j].Height = this.listBox1.ItemHeight;
                cks[j].Width = 15;
                cks[j].Location = new Point(0, this.listBox1.ItemHeight * j);
                this.listBox1.Controls.Add(cks[j]);
                this.listBox1.Items.Add(dt.Rows[j]["name"].ToString());
            }
            this.listBox1.DrawMode = DrawMode.OwnerDrawFixed;
            this.listBox1.DrawItem += new DrawItemEventHandler(listBox1_DrawItem);
        }

Edited by Nick Evan: Fixed formatting

0

if my checklistbox contains 112 items. what should i do to disable item 100 and 101, without increasing number of items?

0

i have 112 items in checklist box.i want to disable items from 48 to 112.please help me

0

As pritishdeshmuk mentioned ,

just add the condition

if (j <= 10)
                     {
                         for (int j1 = j; j1 < 20; j1++)
                         {
                             cks[j].Enabled = false;
                         }
                     }

Hope this will help you

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.