Property grid - Formatting date time

0
0

Hello,

How to format property field to show datetime in format “yyyy-MM-dd”?

Ex

public class SomeProperty {

public DateTime DateOdBirth  { get; set; }

// other properties

}

//..code…

propertyGrid1.SelectedObject = new SomeProperty();

Thanks,

Valeriano

 

 

 

  • You must to post comments
0
0

As a follow on question, I use FormatDateTime in my vb desktop app as it responds to the local date format of the computer.  How can I handle local date formatting with Wisej?  This has proven to be a problem in previous apps since many of my users are from Europe and Australia and one of the key dates I display is an expiration date.  It’s no problem internally in the app but it does create some unnecessary support requests.

  • You must to post comments
1
0

Small correction.

It should rather be:

if (e.GridItem?.PropertyDescriptor?.Name == “LastUsed”)
{
e.CellStyle.Format = “dd.MM.yyyy”;
}

Best regards
Frank

  • You must to post comments
0
0

Hi,

thanls, I try it.

Best regards,

Valeriano Simeone

  • You must to post comments
0
0

Hi Valeriano,

usually this is done with TypeConverters (as in Winforms).

Wisej adds a PropertyValueFormatting event that you can use:

pg

This shows 2 options, either format all DateTime properties in the PG or just a particular one (that is called “LastUsed” in this sample.

Hope that helps.

Best regards
Frank

Attachment
  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.