T
Trollpower
Dear NG,
ive got the following problem with databinding, and i hope someone can
help me out there.
Ive a simple form wit a few controls. With the DateTimePicker the user
can choose a date and also a time. If the user clicks on a Button the
choosen Date and Time are put into a ArrayList. I put the ArrayList
into a ListBox to show the choosen date and time.
Now the ListBox sould show the values, but nothing happens. The
following code shows how i use the Databinding:
//Constructorcode
this.dateTimes = new ArrayList();
listBox1.DataSource = this.dateTimes;
listBox1.DisplayMember = "DateTimeString";//DateTimeString is a
formated string of the DateTimeObject-class with additional functions
//Eventmethod of the button
private void button1_Click(object sender, System.EventArgs e)
{
DateTime dateTime = new DateTime(this.m_picker.Value.Year,
this.m_picker.Value.Month,
this.m_picker.Value.Day,
Convert.ToInt32(this.comboBox1.SelectedItem),
Convert.ToInt32(this.comboBox2.SelectedItem),
0);
DateTimeWrapper dtw = new DateTimeWrapper(dateTime);
if(!this.dateTimes.Contains(dtw))
{
dateTimes.Add(dtw);
}
else{
MessageBox.Show("Time allready set!");
}
}
As far as i understand DataBinding, i only have to define a source for
the control, and as soon as the data changes within the source, the
control refreshes its shown values.
Any help on this problem is appreciated.
Thanks in advance
Jens
ive got the following problem with databinding, and i hope someone can
help me out there.
Ive a simple form wit a few controls. With the DateTimePicker the user
can choose a date and also a time. If the user clicks on a Button the
choosen Date and Time are put into a ArrayList. I put the ArrayList
into a ListBox to show the choosen date and time.
Now the ListBox sould show the values, but nothing happens. The
following code shows how i use the Databinding:
//Constructorcode
this.dateTimes = new ArrayList();
listBox1.DataSource = this.dateTimes;
listBox1.DisplayMember = "DateTimeString";//DateTimeString is a
formated string of the DateTimeObject-class with additional functions
//Eventmethod of the button
private void button1_Click(object sender, System.EventArgs e)
{
DateTime dateTime = new DateTime(this.m_picker.Value.Year,
this.m_picker.Value.Month,
this.m_picker.Value.Day,
Convert.ToInt32(this.comboBox1.SelectedItem),
Convert.ToInt32(this.comboBox2.SelectedItem),
0);
DateTimeWrapper dtw = new DateTimeWrapper(dateTime);
if(!this.dateTimes.Contains(dtw))
{
dateTimes.Add(dtw);
}
else{
MessageBox.Show("Time allready set!");
}
}
As far as i understand DataBinding, i only have to define a source for
the control, and as soon as the data changes within the source, the
control refreshes its shown values.
Any help on this problem is appreciated.
Thanks in advance
Jens