Question count rows in datagridview and refresh the number after adding new row

IrinoSayuri

New member
Joined
Feb 6, 2014
Messages
1
Programming Experience
Beginner
Hi, I'm working on a project to school and I have a little problem. I have a label where, on Load of the form, I count the rows of the datagrid in the same form. The code is: me.label2.text = "Number of rows: " & me.datagridview.rows.count. It works fine, but when I add a row via another form, it doesn't refresh. I tried refreshing the label, refreshing the form, puttng this code onto the OK button on form 2 but nothing refreshes the value. The datagrid gets data from .txt file. I have to hand it in tommorow and I'm really desperate. Thanks for your help.
 
You need to execute that code in the form that contains the Label and DataGridView and you need to execute it when the number of rows changes. Where's the code that changes the number of rows? Put it after that. Presumably this second form is being displayed by calling its ShowDialog method so the code would go somewhere after that.
 
Back
Top