-
Mar 7th, 2018, 06:13 AM
#1
Thread Starter
Member
[RESOLVED] create empty rows in a datagrid at end of a progression
Hi all.
I have a datagridview filled form a datab in access.It comprises of five fields.The database is a student database the fields are
number name exam score overall score. and they are presented like this
1 angie simms history 92 123
2 angie simms math 92 123
3 angie simms english 67 114
4 angie simms science 72 128
1 andy davies science 67 104
2 andy davies math 81 111
3 andy davies history 56 98
1 dave baker geog 82 114
2 dave baker history 82 114
3 dave baker math 82 114
4 dave baker english 82 114
5 dave baker science 82 114
6 dave baker french 82 114
Notice in column 1 each student record has their own record numbers
and these can vary from 2 upto 12.So in the above eg angie has 4 records,andy 3 and dave 6.What I wanted to do is create an empty row between each student record ,and I assume that there would have to be a loop involved which would take its cue from the first column of numbers for each student.So the above would then look like this.
1 angie simms history 92 123
2 angie simms math 92 123
3 angie simms english 67 114
4 angie simms science 72 128
empty row
1 andy davies science 67 104
2 andy davies math 81 111
3 andy davies history 56 98
empty row
1 dave baker geog 82 114
2 dave baker history 82 114
3 dave baker math 82 114
4 dave baker english 82 114
5 dave baker science 82 114
6 dave baker french 82 114
I can do this in excel but am baffled as to how to do it in vb.net.Any suggestions most welcome
regards
lilmelight
Last night I dreamt I went to Manderley again
-
Mar 7th, 2018, 04:26 PM
#2
Re: create empty rows in a datagrid at end of a progression
If your using a datatable as the datagridview datasource and you have the rows ordered by name, number. Then you could do something like this,
Code:
Dim chk As String = dt.Rows(0).Item("name").ToString
For i As Integer = 0 To dt.Rows.Count - 1
If chk <> dt.Rows(i).Item("name).ToString Then
chk = dt.Rows(i).Item("name).ToString
Dim row As DataRow = dt.NewRow
dt.Rows.InsertAt(row, i)
End If
Next
Me.DataGridView1.DataSource = dt
-
Mar 8th, 2018, 04:29 PM
#3
Thread Starter
Member
Re: create empty rows in a datagrid at end of a progression
Hi wes4dbt
Nice piece of code and works great.Thats just what I wanted.Many thanks for that.
Kind Regards
LL
Last night I dreamt I went to Manderley again
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|