[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] SQLSTRING1 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#800000]"SELECT emp_no, emp_name, sel FROM Emp_Profile ORDER BY emp_no"[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] DAdapter1 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] OleDbDataAdapter = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] OleDbDataAdapter(SQLSTRING1, OleDbConnection1)[/SIZE]
[SIZE=2]DataSet1.Clear()[/SIZE]
[SIZE=2]DAdapter1.Fill(DataSet1, [/SIZE][SIZE=2][COLOR=#800000]"Emp_Profile"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#008000]'Set the DataGrid properties to bind it to our data[/COLOR][/SIZE]
[SIZE=2]Emp_Grid.DataSource = DataSet1[/SIZE]
[SIZE=2]Emp_Grid.DataMember = [/SIZE][SIZE=2][COLOR=#800000]"Emp_Profile"[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Declare objects for the DataGrid[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] objDataGridTableStyle [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DataGridTableStyle()[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] objTextCol [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DataGridTextBoxColumn()[/SIZE]
[SIZE=2][COLOR=#008000]'set the AlternatingBackColor property[/COLOR][/SIZE]
[SIZE=2]objDataGridTableStyle.AlternatingBackColor = Color.WhiteSmoke[/SIZE]
[SIZE=2][COLOR=#008000]'Set the AlternatingBackColor property[/COLOR][/SIZE]
[SIZE=2]objDataGridTableStyle.MappingName = [/SIZE][SIZE=2][COLOR=#800000]"Emp_Profile"[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Set the MappingName for the first column[/COLOR][/SIZE]
[SIZE=2]objTextCol.MappingName = [/SIZE][SIZE=2][COLOR=#800000]"emp_no"[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Set the new HeaderText[/COLOR][/SIZE]
[SIZE=2]objTextCol.HeaderText = [/SIZE][SIZE=2][COLOR=#800000]"Emp. No."[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Set the width of the column[/COLOR][/SIZE]
[SIZE=2]objTextCol.Width = 60[/SIZE]
[SIZE=2][COLOR=#008000]'Add the column to the DataGridTableStyle[/COLOR][/SIZE]
[SIZE=2]objDataGridTableStyle.GridColumnStyles.Add(objTextCol)[/SIZE]
[SIZE=2][COLOR=#008000]'Get a new reference to the DataGridTextBoxColumn[/COLOR][/SIZE]
[SIZE=2]objTextCol = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DataGridTextBoxColumn()[/SIZE]
[SIZE=2][COLOR=#008000]'Set the MappingName for the second column[/COLOR][/SIZE]
[SIZE=2]objTextCol.MappingName = [/SIZE][SIZE=2][COLOR=#800000]"emp_name"[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Set the new HeaderText[/COLOR][/SIZE]
[SIZE=2]objTextCol.HeaderText = [/SIZE][SIZE=2][COLOR=#800000]"Employee Name"[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Set the width of the column[/COLOR][/SIZE]
[SIZE=2]objTextCol.Width = 110[/SIZE]
[SIZE=2][COLOR=#008000]'Add the column to the DataGridTableStyle[/COLOR][/SIZE]
[SIZE=2]objDataGridTableStyle.GridColumnStyles.Add(objTextCol)[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] DataGridCheckBoxCol [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DataGridViewCheckBoxColumn[/SIZE]
[SIZE=2][COLOR=#0000ff]With[/COLOR][/SIZE][SIZE=2] DataGridCheckBoxCol[/SIZE]
[SIZE=2].HeaderText = [/SIZE][SIZE=2][COLOR=#800000]"Select"[/COLOR][/SIZE]
[SIZE=2].Name = [/SIZE][SIZE=2][COLOR=#800000]"sel"[/COLOR][/SIZE]
[SIZE=2].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells[/SIZE]
[SIZE=2].FlatStyle = FlatStyle.Standard[/SIZE]
[SIZE=2].CellTemplate = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DataGridViewCheckBoxCell[/SIZE]
[SIZE=2].CellTemplate.Style.BackColor = Color.Beige[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]With[/COLOR][/SIZE]
[SIZE=2][U]Emp_Grid.Columns[/U].Insert(0, DataGridCheckBoxCol)[/SIZE]