I'm trying to create a win forms application where a user can fill in events that will happen each day of the year. The textboxes will be generated by a script. The textbox needs to be given the ID of the day and month so it can be found when it is saved. But the problem is the form application is blank when run. Help a begginer out please.

namespace WindowsFormsApplication2
    public partial class Form1 : Form
        DateTime Current_Year = new DateTime(DateTime.Now.Year, 1, 1);
        public TextBox[] TxBxArray = new TextBox[366];

        public Form1()
            int year_length = 365;
            if (DateTime.IsLeapYear(DateTime.Now.Year)) year_length = 366;
            for (int i = 0; i < year_length; i++)
                    TxBxArray[i] = new TextBox();
                    TxBxArray[i].Name = Current_Year.ToString("dd/MM");
                    TxBxArray[i].Location = new System.Drawing.Point(20, 30 + 40 * i);
                    TxBxArray[i].Size = new System.Drawing.Size(184, 20);

Edited by DaemonToad3: n/a

5 Years
Discussion Span
Last Post by DaemonToad3

You have to add your textboxes to the control collection of the form.
this refers to the form.
There is also an AddRange method.

Edited by ddanbe: n/a


The only problem in my script is that all the dates are the 01/01. Why isnt the date increasing?

Edited by DaemonToad3: n/a


You didnt set any varible to change it. You have to do it:

Curent_Year = Current_Year.AddDays(1); //on the end of the code!

I have a service based database called Events and a datasource called EventsDataSet and a table called Events within the database and a date and event collumn in the table. When I want to save I want a new row to be added to the table. Im strugling to add the new row in code. Could I have help?

EventsDataSet.EventsRow newEventsRow = 
EventsDataSet.EventsRow.NewEventsRow(); //does not contain a definition for 'NewEventsRow'

newEventsRow.date = TxBxArray[i].Name;
newEventsRow._event = TxBxArray[i].Text;

EventsDataSet.Events.Rows.Add(NewEventsRow); // The name 'NewEventsRow' does not exist in the current context

What are my needed corrections

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.