hi...i m again here...
i have a datagridview on a form which contains studentname (in alphabetical order) and a blank rollno field according to the particular class.Now what i m suppose to do is to assign roll no on button click, starting from first student to last student.
Roll no is like 11DCE001...For eg:-
Roll No StudentName
11DCE001 A
11DCE002 B
11DCE003 C
....... .
....... .
til last row....
We can take a textbox to define the starting value..and checkboxes if needed..
please assist me on how to acccomplish this task.
sidyusuf 0 Light Poster
Recommended Answers
Jump to PostFor i = 0 To DataGridView1.Rows.Count - 1 DataGridView1.Item(0, i).Value = Mid("11DCE000", 1, 8 - (i + 1).ToString.Length) + (i + 1).ToString Next
Jump to PostYou can do it this way:
Private Sub button1_Click(sender As Object, e As EventArgs) Dim couter As Integer = 1 For i As Integer = 0 To dataGridView1.Rows.Count - 1 If Not dataGridView1.Rows(i).IsNewRow Then dataGridView1("rollNo", i).Value = [String].Format("{0}-{1}", "11", System.Math.Max(System.Threading.Interlocked.Increment(couter),couter - 1).ToString().PadLeft(4, "0"C)) End If Next End …
All 8 Replies
adam_k 239 Master Poster
sidyusuf 0 Light Poster
adam_k 239 Master Poster
sidyusuf 0 Light Poster
adam_k 239 Master Poster
Mitja Bonca 557 Nearly a Posting Maven
sidyusuf 0 Light Poster
sidyusuf 0 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.