我在當前中可以使用me.components.Components.counts來查找總共有多少個組件,如果我使用form名稱的時候就不能顯示components屬性,請問該如何在其它Form呼叫當前Form的Components?

uj5u.com熱心網友回復:
你在 components 上右鍵\轉到定義,會打開 .Designer.vb 檔案。會看到改成員是 Private 的,可以改為 Public 試試。
但是 .Designer.vb 檔案是設計器修改的,最好在 .vb 檔案中封裝一個公共屬性。
uj5u.com熱心網友回復:
試了,還是不行

uj5u.com熱心網友回復:
剛才又試了一下,如果我是 直接定義這個指定的FORM就可以參考到components屬性dim newForm as new frmSecond
newForm.components.Components.Count
如果我是將FORM做為引數傳遞給另外一個函式,在函式中就不能參考,如:
getComponents(frmSecond)
sub getComponents(frmForm as Form)
frmForm.co....就不會出現
End Sub
uj5u.com熱心網友回復:
sub getComponents(frmForm as frmSecond)
frmForm.components...
End Sub
uj5u.com熱心網友回復:
謝謝,
不過傳入的form需要指定為frmSecond才會出現,如果剛開始只知道是form,有可能是frmFirst,而不是frmSecond,是否有辦法呢??
uj5u.com熱心網友回復:
定義一個介面讓 frmFirst、frmSecond 實作,函式引數宣告為介面型別。轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/62440.html
標籤:控件
