When i double click on an special date in the calender the current date which has been chosen automatically added to a list box
How can i do that ?Please Guide me.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jose SaizRank #5,346 · 302 reputationPosted May 23, 2014, 3:04 PM EDT
listbox.items.add(calendar.date.picked)
Quick and dirty
Instantiate the listbox control
ListBox lslBox = new ListBox();
// Add the system date mm/dd/yyyy
lslBox.Items.Add(DateTime.Now.ToShortDateString());
Joe WilsonRank #631 · 3.8K reputationPosted May 23, 2014, 10:41 PM EDT
Joe WilsonRank #631 · 3.8K reputationPosted May 23, 2014, 10:55 PM EDT
Ranjit PowarRank #553 · 4.4K reputationPosted May 23, 2014, 11:18 PM EDT
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
listBox1.Items.Add(dateTimePicker1.Value .ToString());
}
Joe WilsonRank #631 · 3.8K reputationPosted May 24, 2014, 3:27 AM EDT
Please Check it.
Ranjit PowarRank #553 · 4.4K reputationPosted May 24, 2014, 3:33 AM EDT
Ranjit PowarRank #553 · 4.4K reputationPosted May 24, 2014, 6:24 AM EDT
private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
{
listBox1.Items.Add(monthCalendar1.SelectionEnd.ToString());
}
Joe WilsonRank #631 · 3.8K reputationPosted May 24, 2014, 9:58 AM EDT
although i want to add every date which i want for example my birth date to the list box.
Thank you
Joe WilsonRank #631 · 3.8K reputationPosted May 25, 2014, 3:35 AM EDT
Joe WilsonRank #631 · 3.8K reputationPosted May 25, 2014, 10:16 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 26, 2014, 2:59 AM EDT
However, you can manufacture you're own using the MouseDown event by calculating the time between events and seeing if it's short enough to be regarded as a double click:
Note that double clicking on the month or a year also causes a selection to be made.
Joe WilsonRank #631 · 3.8K reputationPosted May 26, 2014, 11:28 PM EDT
VulpesRank #55 · 29.2K reputationPosted May 27, 2014, 5:06 AM EDT
At least, that's what it did when I tested it :)
Incidentally, it might be best to set the MonthCalendar's MaxSelectionCount property to 1 to ensure that there's no confusion with other dates that may be selected at the same time.
Joe WilsonRank #631 · 3.8K reputationPosted Jun 14, 2014, 2:26 AM EDT
VulpesRank #55 · 29.2K reputationPosted Jun 14, 2014, 11:58 AM EDT
Joe WilsonRank #631 · 3.8K reputationPosted Jun 15, 2014, 2:43 AM EDT
What do you think about this way?
Joe WilsonRank #631 · 3.8K reputationPosted Jun 15, 2014, 2:45 AM EDT
VulpesRank #55 · 29.2K reputationPosted Jun 15, 2014, 7:01 AM EDT
Much better idea :)
Joe WilsonRank #631 · 3.8K reputationPosted Jun 17, 2014, 6:48 PM EDT