c# - DataGrid displaying the wrong dateformat -


i'm displaying information case exist in datagrid.

in ms access database date stored in datetime format , looks : dd/mm/yyyy.

the problem when displayed on datagrid when program runs, format change mm/dd/yyyy.

the thing makes me lost when display in messagebox content of concerned cells before assign datatable datagrid i've got right format (dd/mm/yyyy).

i've tried change datetimemode same format displayed.

someone got tips fix problem ? give code below :

datatable temp = dt.clone();

            temp = (from nardin in dt.asenumerable().distinct()                     nardin["numero client"].tostring() == _centerid.tostring()                     select nardin).copytodatatable();                  removeduplicates(temp, "numero dossier");               foreach (datarow row in temp.rows)             {                 messagebox.show(row["date intervention"].tostring()); //this gives me datetime format i'd display             }              existingcase.itemssource = temp.asdataview(); //once assigned datagrid datetime format not same above 

actually datagrid declared in xaml file :

   <datagrid  selectionunit="fullrow" selecteditem="{binding selectedbi, mode=twoway}" autogeneratecolumns="true"   margin="0,167,12,167" name="existingbi"  width="588" horizontalalignment="right">         <datagrid.rowstyle>             <style targettype="{x:type datagridrow}">                 <eventsetter event="mousedoubleclick" handler="resultdatagridbi_mousedoubleclick"/>             </style>         </datagrid.rowstyle>     </datagrid> 

i'm binding datatable with: existingcase.itemssource = temp.asdataview();

in advance, !

try this:

add startup event handle in app.xaml file:

<application x:class="datagridaddrows.app"          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"          startup="application_startup" ... /> 

in app.xaml.cs add this:

public partial class app : application {     private void application_startup(object sender, startupeventargs e)     {         frameworkelement.languageproperty.overridemetadata(typeof(frameworkelement),             new frameworkpropertymetadata(system.windows.markup.xmllanguage.getlanguage(system.globalization.cultureinfo.currentculture.ietflanguagetag)));     } }             

now, date should displayed depending on current culture.

note: stringformat suitable only display date. if want edit cell date, such format dd/mm/yyyy, entering data in way dd/mm/yyyy, system expected format mm/dd/yyyy, error appear red border.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -