How in the DataGridView to configure the display of a column with data type DataTime, to get the output "Июль 2016" ? When you run the program in Russian localization, of course.

It is clear that you need to set the appropriate format in datagridviewcolumn1.DefautCellStyle.Format . But which one? I can not find a description of the possible formats. "MSDN String Custom Date and Time Formats" is not appropriate. For example, if you specify the format "M" , then we get the output "июля 01" , while in accordance with the above link, you would have to receive "7"

    1 answer 1

    "MMMM" The full name of the month.
    "yyyy" The year as a four-digit number.

    https://msdn.microsoft.com/ru-ru/library/8kb3ddd4(v=vs.110).aspx
    Respectively:

     DefaultCellStyle.Format = "MMMM yyyy"; 

    UPD. Why DefaultCellStyle.Format="M" shows "July 01" instead of "7".
    According to the formats described by a single character, Format tries to look at the Standard Date and Time Format Strings. . And there the “M” is really the Month / day pattern.
    And that "M" , which we both talked about is described in Custom Date and Time Format Strings, and to use it you need to write DefaultCellStyle.Format="%M"

    • You give the same link as me in the question. Explain why the correspondence does not work, if you just specify "M"? - 4per
    • Because: "M" The month, from 1 through 12. number of the month, without a lead-zero. The name is MMMM. Year - yyyy. Combining we get the required. - Zufir
    • And, it seems, I understood what the question is except "how to get July 2016": "we get at the output" July 01 "" instead of "7". Show the code of data binding, maybe there is a conversion? - Zufir
    • And if you remove DefautCellStyle.Format="M" - is the full date issued? - Zufir
    • Yes. 07/01/2015 00:00:00 - 4per