Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The documentation for <a href="http://msdn.microsoft.com/en-us/library/system.data.datatable.locale.aspx" rel="nofollow"><code>DataTable.Locale</code></a> doesn't say anything about setting number formats; it says:</p> <blockquote> <p>Gets or sets the locale information used to compare strings within the table.</p> </blockquote> <p>So it may not do what you're expecting it to do.</p> <p>If you're auto-generating columns you may need to store the values as strings in the <code>DataTable</code> instead so you can specify the formatting. Another option is to attach to the <code>AutoGeneratingColumn</code> event to set custom column properties:</p> <p>excerpt from <a href="http://msdn.microsoft.com/en-us/library/cc903950%28v=vs.95%29.aspx" rel="nofollow">MSDN</a> :</p> <pre><code>private void dataGrid1_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e) { // Modify the header of the Name column. if (e.Column.Header.ToString() == "Name") e.Column.Header = "Task"; // Replace the DueDate column with a custom template column. if (e.PropertyName == "DueDate") { // Create a new template column. DataGridTemplateColumn templateColumn = new DataGridTemplateColumn(); templateColumn.Header = "Due Date"; templateColumn.CellTemplate = (DataTemplate)Resources["dueDateCellTemplate"]; templateColumn.CellEditingTemplate = (DataTemplate)Resources["dueDateCellEditingTemplate"]; templateColumn.SortMemberPath = "DueDate"; // ... // Replace the auto-generated column with the templateColumn. e.Column = templateColumn; } // Cancel AutoGeneration of all boolean columns. if (e.PropertyType == typeof(bool)) e.Cancel = true; if (e.PropertyName == "ValueField") { (e.Column as DataGridTextColumn).Binding.StringFormat = "N5"; } } </code></pre> <p>I will say that auto-generating columns is a nice way to quickly prototype a grid but I usually end up directly configuring the columns to specify number formats, etc.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload