Formatting Variables

  • Thread starter Thread starter OutdoorGuy
  • Start date Start date
O

OutdoorGuy

Greetings,

I have a "newbie" question pertaining to formatting. I am experimenting
with the Month Calendar control on a Windows form and simply want to
format (in red) the dates returned (e.g., "e.Start.ToLongDateString()").
I see no "format" command available (as you would find in VB), and
wasn't sure of how to go about this. Any ideas?

private void monthCalendar1_DateChanged(object sender,
System.Windows.Forms.DateRangeEventArgs e)
{
textBox1.Text = "You selected: " +
e.Start.ToLongDateString() + " to " +
e.End.ToLongDateString();
}

Thanks in advance!
 
I have a "newbie" question pertaining to formatting. I am experimenting
with the Month Calendar control on a Windows form and simply want to
format (in red) the dates returned (e.g., "e.Start.ToLongDateString()").
I see no "format" command available (as you would find in VB), and
wasn't sure of how to go about this. Any ideas?

private void monthCalendar1_DateChanged(object sender,
System.Windows.Forms.DateRangeEventArgs e)
{
textBox1.Text = "You selected: " +
e.Start.ToLongDateString() + " to " +
e.End.ToLongDateString();
}

Try this :

textBox1.Text = String.Format("You selected {0:D} to {1:D}", e.Start, e.End)

Joanna
 
Thanks so much for the code. However, I was actually wanting to format
the text in either bold or in red. Any idea as to how to do that?

Thanks!
 
Back
Top