Question visibility of 3 first row

pooya1072

Well-known member
Joined
Jul 5, 2012
Messages
84
Programming Experience
Beginner
hi
i have 5 datagridview in my form . i create a Sub to fill all these 3 datagridview.i want this sub also set the visibility of 3 first row of these datagridviews to false . here is my code :
VB.NET:
Public cn As New System.Data.SqlClient.SqlConnection
Public DA As SqlDataAdapter
Public DT As New DataTable()
Public SqlCommandBuilder As SqlCommandBuilder
Public Sub FillDataGridViews(ByVal dgv As DataGridView)
        cn.ConnectionString = "Data Source=pooyan-pc\SQLEXPRESS;Initial Catalog=Faravaresh Produce Control;UID=pooya1072;password=ahmadreza"
        NFFeedDataAdapter = New SqlDataAdapter("select * from T1", cn)
        NFFeedDataAdapter.FillSchema(NFFeedDataTable, SchemaType.Source)
        NFFeedDataAdapter.Fill(NFFeedDataTable)
        SqlCommandBuilder = New SqlCommandBuilder(NFFeedDataAdapter)
        dgv.DataSource = NFFeedDataTable
        dgv.CurrentCell = Nothing
        dgv.Rows(0).Visible = False
        dgv.Rows(1).Visible = False
        dgv.Rows(2).Visible = False
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        FillDataGridViews(dgv1)
        FillDataGridViews(dgv2)
        FillDataGridViews(dgv3)
End Sub
the problem is that in 2 first dgv (dgv1 and dgv2) the visibility of first row (rows(0)) dont set to false.the visibility of rows(1) and rows(2) is set to false and is ok . only the visibility of all 3 rows of last dgv (dgv3) is false and ok.
can you help me ?
 
as much as I've tried, I cannot reproduce your error. I even extended it to 10 datagridviews and all 10 hid the first 3 rows using your code.

Can you access the grids when this happens? Is it possibly a refresh issue?
Maybe put a me.refresh after the last line in your sub.

Try putting the code that you have in form_load inside a button and click it and see if it does the same thing.
 
as much as I've tried, I cannot reproduce your error. I even extended it to 10 datagridviews and all 10 hid the first 3 rows using your code.

Can you access the grids when this happens? Is it possibly a refresh issue?
Maybe put a me.refresh after the last line in your sub.

Try putting the code that you have in form_load inside a button and click it and see if it does the same thing.

thanks...
i debug my program line by line and check the visibility of rows . for dgv1 and dgv2 , visibility of first row, exactlly, change from false to true .i cant understand what happen.
 
Back
Top