仅通过该表单更改表单属性 [英] change form property through that form only

查看:113
本文介绍了仅通过该表单更改表单属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在运行应用程序时更改表单属性,例如添加更多按钮文本框并移动按钮的位置,增加表单大小

i want to change form property to be change during running app like adding more button text box and shift the location of button, increase size of form

推荐答案

无人阻止你这样做。

只是谷歌搜索会帮助你在 howto 方面:C#以编程方式将控件添加到表单 [ ^ ]。

移动和调整大小(甚至表格本身)只是改变它们的属性。
Nobody prevents you doing it.
Just Googling for would help you on the howto side: "C# programmatically adding controls to a form"[^].
Moving and resizing (even the Form itself) it is just a matter of changing their properties.


试试

try
Label lbl = new Label();

           for (int x = 0; x <= 3; x++)
           {
               //create new label location after each loop
               //by multiplying the new value of variable x by 5, so the new label
               //control will not overlap each other.
               lbl.Location = new System.Drawing.Point(52 + (x * 5), 58 + (x * 5));
               //create new id and text of the label
               lbl.Name = "label_" + x.ToString();
               lbl.Text = "Label " + x.ToString();

               this.panel1.Controls.Add(lbl);
           }


这篇关于仅通过该表单更改表单属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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