0

i want that as many date time pickers must get enabled in the form as the no. selected in the combobox.
Please help

2
Contributors
3
Replies
5
Views
8 Years
Discussion Span
Last Post by ddanbe
0

Do you want to create the DateTimePickers at run time? Please explain a bit more on what you want.

0

i mean that,suppose there are values from 1-10 in the combobox.suppose 1 select 4 then 4 datetime pickers appear bsid it.please help

0

Perhaps this will help: Create an empty forms application and put a NumericUpDown control on the form and add a numericUpDown1_ValueChanged event handler. For the rest fill in this code:

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        private const int MaxPickers = 10;
        private DateTimePicker[] DatetimeGetters = new DateTimePicker[MaxPickers];

        public Form1()
        {
            InitializeComponent();
        }

        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            NumericUpDown MyUpDown = sender as NumericUpDown;
            int count = (int)MyUpDown.Value;
            for (int i = 1; i <= count; i++)
            {
                DatetimeGetters[i] = new DateTimePicker();
                DatetimeGetters[i].Location = new System.Drawing.Point(100, 70 + i * 30);
                DatetimeGetters[i].Name = "dateTimePicker" + i.ToString();
                DatetimeGetters[i].Size = new System.Drawing.Size(200, 20);
                this.Controls.Add(DatetimeGetters[i]);
            }
        }
    }
}

No testing for overflow conditions has been done here, just the bare essentials.

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.