简体   繁体   中英

How I can get the rowcount of a tableLayoutPanel from another form?

I have a form1 and a button. This button created a new form with a TableLayoutPanel (already filled for the test).

Is it possible to get the RowCount and display it in the button text in the first form (form1)?

If the TableLayoutPanel on the second form is initialized onload, then you can create a property/method that returns the count. On form1 when you load form2 on button click, the code might look something like this.

Form2 frm2 = new Form2();
frm2.show();
int count = frm2.GetTableRowCount()
btn.Text  = count.ToString();

Where GetTableRowCount() method on form 2 returns the table row count.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM