Datagrid styles - setting styles for a data grid in c#.NET or any .NET language. Changing Look and feel of datagrid - seting DatagridTable styles using datagridtablestyle. |
|||
DATAGRID STYLES DATA GRIDC# Tutorials |
|||
|
|
|||
|
|
|||
DATAGRID STYLES DATA GRIDLearn Tutorials |
|
Datagrid styles - setting styles for a data grid in c#.NET or any .NET language. Changing Look and feel of datagrid - seting DatagridTable styles using datagridtablestyle.
Example code for Datagrid Styles data grid: DataGrid Styles This is the DataGrid Hierarchy: DataGrid has DataSet with several DataTables each has own DataGridTableStyle of which each can have several DataGridColumnStyles accessed with //can modify later with dg.TableStyles[0].GridColumnStyles[2].Width=100; ------------------------------------------------------------------------------------------------------------------------- private void configureStyles(DataGrid dg) { DataGridTableStyle tableStyle = new DataGridTableStyle(); //specify which table in the dataset for the grid we want to create style for tableStyle.MappingName="DetailReport"; tableStyle.AlternatingBackColor = Color.Bisque; //col names: TransactionDate|Description|Amount|ExpensedTo //for each column, set properties DataGridTextBoxColumn col1= new DataGridTextBoxColumn(); col1.HeaderText = "Trans. Date"; col1.MappingName="TransactionDate"; col1.Width=100; DataGridTextBoxColumn col2= new DataGridTextBoxColumn(); col2.HeaderText = "Description"; col2.MappingName="Description"; col2.Width=200; DataGridTextBoxColumn col3= new DataGridTextBoxColumn(); col3.HeaderText = "Amount"; col3.MappingName="Amount"; col3.Width=100; DataGridTextBoxColumn col4= new DataGridTextBoxColumn(); col4.HeaderText = "Expensed To Itemization"; col4.MappingName="ExpensedTo"; col4.Width=400; //add the DataGridColumnStyles to the DataGridTableStyle tableStyle.GridColumnStyles.AddRange(new DataGridColumnStyle[]{col1,col2,col3,col4}); //add the style to the DataGrid dg.TableStyles.Add(tableStyle); //can modify later with dg.TableStyles[0].GridColumnStyles[2].Width=100; } |
Home
CSHARP Arrays in c sharp C sharp array objects C sharp separators context menu Compare dates csharp datetime Context menu c sharp Context menus csharp example Controls c sharp dynamically Database access c sharp Database access with ADO NET DataGrid c sharp Datagrid dataset csharp NET Datagrid Styles data grid Datasets listview dropdown selectbox Dialogbox csharp dialog box Drag and drop csharp Listview combo box csharp Looping through hashtable NET NET collections tutorial NET crawler safe url One row from dataset Output datetime csharp Popup form csharp Try catch c sharp |
||||||
![]() | |||||||