jamesdean666
asked on
C# DateTimePicker set Date
In the code below, I am attempting to set the date that displays in my datetimepicker after I hit the Drop Down arrow. I would like to displays today's date in the drop down calendar once I click the Drop Down arrow. The code I am have below is not working.
private void dtpChangeEffDate_DropDown( object sender, EventArgs e)
{
if (this.dtpChangeEffDate.Val ue.ToShort DateString () != DateTime.Now.ToShortDateSt ring())
{
this.dtpChangeEffDate.Valu e = DateTime.Now;
this.dtpChangeEffDate.Text = DateTime.Now.ToShortDateSt ring();
}
}
private void dtpChangeEffDate_DropDown(
{
if (this.dtpChangeEffDate.Val
{
this.dtpChangeEffDate.Valu
this.dtpChangeEffDate.Text
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I can't quite get that to work.
Can you please provide the code?
Can you please provide the code?
What is this event for---> private void dtpChangeEffDate_DropDown( object sender, EventArgs e)
if it's for a dropdown, then are you trying to add a new select option once it opened?
if it's for a dropdown, then are you trying to add a new select option once it opened?
ok...dropdown calendar...not a dropdownlist...got it...
can i see your code so far on how you're creating this dropdown so that i can have a better understanding....thanks
ASKER
I derive the value from a call to a method (ChangeEffectiveDate) in my Gateway with the code below:
this.dtpChangeEffDate.Valu e = this.mGatwy.ChangeEffectiv eDate(this .txtPolNum ber.Text.T oUpper(), pEffDate);
this.dtpChangeEffDate.Valu
and by your Gateway, I assume you mean your Main class and that this is a desktop application?
ASKER
correct.
ASKER
Thnx.
dr.Items.Add(listItem);