C#代码根本不起作用 [英] C# Code not working At All

查看:83
本文介绍了C#代码根本不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,该代码无法正常工作,而另一种形式是label.text ="900";然后使form2.label ="900";然后我们将form2中的文本转换为一个值,然后我将其设置为form2的宽度加上文本框中的值,因此form2的宽度应该更长,但不是!代码有什么问题?

for some reason this code isn''t working, on the other form the label.text = "900"; and that made the form2.label = "900"; and then we converted the text in form2 to a value, and then i made it so form2''s width plus the value that is in the textbox, so the form2''s width should be longer, but its not!?. whats the problem with the code?

private void ShortCut_Load(object sender, EventArgs e)
{
         int value = 0;
         try
         {
                  value = Convert.ToInt32(form2size.Text);
         }
         catch
         {}
         this.Size = new Size(this.Size.Width + value, 130);
}

推荐答案



根据您的帖子,我认为您想更改表格的width属性值.您可以在像素中使用Unit.Pixel()方法,也可以在百分比中使用Unit.Percentage()方法.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.unit.pixel.aspx [ http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.unit.percentage.aspx [


Based on your post, i think you want to change the width attribute value of the forms. You can use Unit.Pixel() method in pixel or Unit.Percentage() method in percentage.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.unit.pixel.aspx[^]


http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.unit.percentage.aspx[^]


您正在使用form2size.Text,是不是错过了什么那里?您要获取表单的文本值还是从表单中的标签/文本框中获取文本值?
You''re using form2size.Text, aren''t you missing something there? Do you want to get the form''s text value or the text value from a label/textbox in the form?


这篇关于C#代码根本不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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