First we first define a DataTable and a DataRow Private IDTB_TEMP AS DATATABLE Private idRW_ROW AS DATAROW Private Sub getDataTable () idtb_temp.columns.add ("prdodr_subodr_code") '' defines the column name of DataTable
idtb_temp.TableName = "SearchTable" Dim ldcl_header As Windows.Forms.DataGridTextBoxColumn Dim ldgts_styles As New Windows.Forms.DataGridTableStyle ldgts_styles.SelectionForeColor = System.Drawing.Color.Yellow '' 'foreground color of the selected row, i.e., font color ldgts_styles.SelectionBackColor = System.drawing.color.brown '' 'Select the background color of the row
Color ldgts_styles.BackColor 'color ldgts_styles.AlternatingBackColor datagrid word will be displayed = System.Drawing.Color.Cyan' ldgts_styles.ForeColor = System.Drawing.Color.Coral '' '' datagrid odd lines displayed = System. Drawing.color.cyan '' DataGrid Doll Double Digital Color
LDGTS_STYLES.AllowSorting = false '' '' 'Style Table Definition DataGrid is not allowed to be sorted..
LDGTS_Styles.mappingName = "SearchTable"
ldcl_header = New Windows.Forms.DataGridTextBoxColumn '' 'instantiate a datagridtextboxcolumn ldcl_header.MappingName = "prdodr_subodr_code"' '' defined hereinbefore referenced "column name" ldcl_header.HeaderText = "first column" '' 'in the table show datagrid List text LDCL_HEADER.Readonly = true '' 'Some columns set to read-only LDCL_Header.TextBox.Borderstyle = Border.Drawing.forecolor = system.drawing.color.red
ldgts_styles.GridColumnStyles.Add (ldcl_header) For i As Integer = 0 To 7 idrw_row = idtb_temp.NewRow idrw_row.Item ( "prdodr_subodr_code") = "of" & i & "OK" idtb_temp.Rows.Add (idrw_row)
NEXT
IDTB_TEMP.DEFAULTVIEW.ALLLOWNEW = false me.dataGrid1.tablestyles.add (ldgts_styles) me.dataGrid1.datasource = idtb_temp end sub