Hi, I try to develop Forms App which will count my working hours, taxes, expenses etc...
At moment Iam working on calendar. On the first form I have combobox which sends the name of month into the ReturnNumberOfDaysInCurrentMonth().

The Class returns the number of month for DateTime.DaysInMonth(int,int), which returns the quantity of days.

That's the problem. I need to create dynamically changeable set of textboxes according to quantity of days in current month. Something like:

int numbeOfDays;
TextBox tb=new TextBox();
for(int i=0; i<=numberOfDays; i++)

Does anyone can advice me something? Thank you.

Start a new forms app and fill in the code below. Hope it helps you out.

namespace WindowsFormsApplication1
    public partial class Form1 : Form
        public Form1()
            int numberOfDays = 30;
            int Xpos = 10;
            int Ypos = 0;
            for (int i = 0; i <= numberOfDays; i++)
                Ypos = 20 * (i % 6) + 3;
                if ((i % 6) == 0) Xpos += 50;
                TextBox tb = new TextBox();
                tb.Location = new Point(Xpos, Ypos);
                tb.Width = 50;
                //other properties for tb here
                this.Controls.Add(tb); //add to form

Uhm you can try this

for(int i = 0 ;i < numberOfDays; i++)
    TextBox tb = new TextBox();
    tb.ID = "txt" + i;


This article has been dead for over six months. Start a new discussion instead.