Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim dt As DataTable = New DataTable("stud")
Dim ds As DataSet = New DataSet() ' Add the new DataTable to the DataSet.
Dim table As New DataGridTableStyle()
table.MappingName = "stud" Dim dc As DataColumn = New DataColumn() With dc .DataType = System.Type.GetType("System.String") .ColumnName = "SR.NO" End With dt.Columns.Add(dc) Dim col_srno As New DataGridTextBoxColumn() With col_srno .MappingName = "SR.NO" .HeaderText = "SR.NO" .Width = 30 .Alignment = HorizontalAlignment.Center .TextBox.Enabled = True .NullText = "" .ReadOnly = True End With With table.GridColumnStyles .Add(col_srno)
End With
ds.Tables.Add(dt) dg2.TableStyles.Add(table) dg2.SetDataBinding(ds, "stud") Dim dr As DataRow dr = dt.NewRow dr("SR.NO") = "1" dt.Rows.Add(dr)
End Sub
Private Sub dg1_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dg1.CurrentCellChanged If dg1.CurrentRowIndex = dg1.VisibleRowCount - 1 Then dg1.Item(dg1.CurrentRowIndex, 0) = dg1.VisibleRowCount dg1.CurrentCell = New DataGridCell(dg1.CurrentRowIndex + 1, 1)
End If End Sub
|
No responses found. Be the first to respond and make money from revenue sharing program.
|