将选项卡重置为设计默认值 [英] Resetting a Tab to the design defaults

查看:87
本文介绍了将选项卡重置为设计默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我设计的TabPage具有使用特定值和可见性创建的文本和框,则在处理过程中某些值会发生更改,而某些框会被隐藏和隐藏,是否可以有一个按钮来重置所有这些更改并重新显示按原始设计的TabPage,还是我必须在按钮的代码内进行硬编码,而不要进行所有更改?我希望这是有道理的!

If I design a TabPage with texts and boxes created with specific values & visibility, then during processing some values get altered and some boxes get hidden & unhidden, is it possible to have a button that resets all these changes and re-displays the TabPage as per the original design, or do I have to hard code within the button''s code the opposite of all the changes I''ve made ? I hope that makes sense !!!

推荐答案

您将需要自己编写此代码.一些控件具有Reset(),Clear()等方法,可以利用这些方法节省一些时间.

我将创建一个Reset()方法,并在此方法中将所有控制值设置为默认值,这样您就可以在整个代码中多次调用此方法.

如果您想让标签页完全回到设计时的状态,我想您总是可以将tabPage变量重新分配给标签页的新实例.
You will need to write this code yourself. Some of the controls have Reset(), Clear(), etc. methods you can make use of to save you some time.

I would create a Reset() method and in this method set all control values to what you want them to be for defaults that way you can call this method many times throughout your code.

If you wanted the tab page back exactly as it was at design time I guess you could always just reassign your tabPage variable to a new instance of your tab page.


我只是想知道.. .当我的(小型& new)项目启动时,我的代码就在开始附近(这是方法",对吗?):

I was just wondering ... when my (small & new) Project starts up, I have this code right near the start (This is a "Method", is that right ?) :

public KALCForm1()
{
    InitializeComponent();

    //Ensure comboBox is empty
    KALCcomboBox1.Items.Clear();

    //Fill comboBox with an entry for each League in the Database
    SqlConnection cs = new SqlConnection(@"Data Source=MEDESKTOP;AttachDbFilename=J:\Users\Gary\Documents\Visual Studio 2010\Projects\KALeagueCup\KALeagueCup\KADatabase.mdf;Initial Catalog=myKADB;Integrated Security=True");
    SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM LEAGUES", cs);

    DataTable dt = new DataTable();

    da.Fill(dt);

    for (int i = 0; i < dt.Rows.Count; i++)
    {
        KALCcomboBox1.Items.Add(dt.Rows[i]["LeagueName"]);
    }
}



如果我想重新显示原始表单,那么是否可以将此代码保存在其他位置并从此处或从其他任何位置调用",或者我是否又想像成Mainframe程序员?!?!?



Could this code be kept elsewhere and "Called" from here and from anywhere else if I wanted to re-display the original form, or am I thinking too much like a Mainframe programmer again ?!?!?


这篇关于将选项卡重置为设计默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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