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

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 3 results
Your Answer

Please first to submit.