C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

Incrementing the serial number in Datagrid Columns


Posted Date: 09 Jul 2004    Resource Type: Articles    Category: .NET Framework
Author: Neelam Kanhaiya ChandwaniMember Level: Bronze    
Rating: 1 out of 5Points: 7



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




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: FileViewer
Previous Resource: .Net Compact Framework Programming
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use