Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
System.Windows.Forms.DataGrid m_DataGrid;
m_DataGrid.TableStyles.Clear();
DataGridTableStyle vStyle = new DataGridTableStyle();
vStyle.AlternatingBackColor = System.Drawing.Color.Bisque;
vStyle.RowHeadersVisible = false;
vStyle.MappingName = "MyTable";
For each column that you have in a DataTable object do:
DataGridTextBoxColumn vColumnStyle= new DataGridTextBoxColumn();
vColumnStyle.TextBox.Enabled = false;
vColumnStyle.TextBox.CanFocus = false;
vColumnStyle.NullText ="";
vColumnStyle.HeaderText = "Column01";
vColumnStyle.MappingName = "Column01";
vColumnStyle.ReadOnly =false/true;
vColumnStyle.Width = 50;
vColumnStyle.Alignment = System.Windows.Forms.HorizontalAlignment.Center;
vStyle.GridColumnStyles.Add(vColumnStyle);
Now bind the DataTable to the grid using a DataAdapter and the Fill() method on the DataTable.
The DataTable is empty and the also the grid.
As in the solution 1, add a row in the DataTable and refresh the grid object.
If you want to set/get the value of an existing cell in the grid then use m_DataGrid[row, col]
object vCell = m_DataGrid[vRow,vColumn]; //get value of an existing cell
object vValue = "....";
m_DataGrid[vRow,vColumn]=vValue; //set the value of an existing cell