以编程方式更改行/列跨度(tablelayoutpanel) [英] Change row/column span programmatically (tablelayoutpanel)

查看:54
本文介绍了以编程方式更改行/列跨度(tablelayoutpanel)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个tablelayoutpanel.2x2-2列2行.

I have a tablelayoutpanel. 2x2 - 2 columns 2 rows.

例如,我在第一行第二列中添加了一个按钮 button1 . button1 的Dock属性设置为Fill.VS Designer允许设置 button1 的列/行跨度属性.

For example, I added a button button1 in a 1 row, second column. button1 has a dock property set to Fill. VS Designer allows to set column/row span properties of button1.

我希望可用性以编程方式更改 button1 的行跨度属性,以便它可以填充所有第二列(第一行和第二行)和可用性以将其重新设置

I want an availability to change row span property of button1 programatically, so it can fill all second column(1 row and second row) and availability to set it back.

如何?

推荐答案

这段代码呢?

private void button1_Click(object sender, EventArgs e)
{
    var control = sender as Control;

    if(control == null)
        return;

    if (1 == tableLayoutPanel1.GetRowSpan(control))
    {
        tableLayoutPanel1.SetRowSpan(control, 2);
    }
    else
    {
        tableLayoutPanel1.SetRowSpan(control, 1);
    }
}

这篇关于以编程方式更改行/列跨度(tablelayoutpanel)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆