Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

How do i add checkBoxes controls near each line of text with one space between the checkBox and the text ?

$
0
0

In the top of the form i did:

double counter;
int counter1;
CheckBox[] _cbs;

In the constructor:

counter = 0;
counter1 = 0;
_cbs = new CheckBox[ScrollLabel._lines.Length];

Then in a button click event i did:

private void button1_Click(object sender, EventArgs e)
        {
         for (int i = 0; i < ScrollLabel._lines.Length; i++)
                {
                    _cbs[i] = new CheckBox();
                    counter += 13.8251925;
                    counter1 += 1;
                    if (counter1 == 3)
                    {
                        _cbs[i].Location = new Point(0, (int)counter);
                        counter1 = 0;
                    }
                    _cbs[i].Size = new Size(10, _cbs[i].Height);
                    this.scrollLabel1.Controls.Add(_cbs[i]);

                }
       }

13.8251925 is the Height of the line. If im not wrong.

The result is:


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>