1
我有一個tabcontrol。 tabcontrol上的每個tabpage都包含一個datagridview。這些是以編程方式創建的。VB.Net datagridview標籤頁上不返回行數,除非用戶已經看過它
後來我正在讀取datagridviews中的值並將它們寫入Word文檔。
如果用戶點擊了標籤頁,則datagridview會報告其正確的行數。
如果用戶尚未查看的標籤頁,在DataGridView .rowcount = 0
有什麼我可以做,以迫使datagridview的,以反映其實際行數?
我導航到包含通過名稱(tcPlanFeeTab)在DataGridView用下面的代碼標籤:
For Each tp As TabPage In frmSvcFee.tcPlanFee.TabPages
'find the fee tab
If tp.Text = tcPlanFeeTab Then 'this is the fee tab
'select the tp so the datagridview is activated
tp.Select()
For Each ctl As Control In tp.Controls 'find the datagridview on the rates tab
If TypeOf ctl Is DataGridView Then
Dim D As DataGridView = ctl
MessageBox.Show(D.RowCount)
+1當前不可見的TabPages也具有奇怪的行爲。 – SSS 2013-02-15 02:22:50
謝謝。我一直因此受到阻礙。我知道grid + tab控件存在,但是直到我看到它們時,它們纔會起作用。 – unholymackerel 2013-02-15 14:29:07
@unholymackerel是的 - 它可能會令人沮喪,並可以吸引很多人。本質上datagridview出於性能原因有兩種形式的「綁定」,一種是實際的數據源,另一種是視覺綁定。第二個綁定只發生在需要時(當網格被可視化呈現時)。 – 2013-02-15 14:56:27