控制的WinForms用户的工作流程 [英] Controlling user workflow in Winforms

查看:152
本文介绍了控制的WinForms用户的工作流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立在C#中的WinForms应用程序,我添加了一个选项卡控件,有三个选项卡。

I'm building a Winforms application in C# and I have added a tab control that has three tabs.

我想限制用户的,直到用户填写第一个选项卡进入第二个标签页的能力。

I want to restrict user's ability to access the second tab page until user fills out the first tab.

我有一个提交按钮的第一个标签,我希望第二个选项卡是能够被访问,当用户点击提交按钮。

I have a submit button the first tab, I want the second tab to be able to be accessed when the user clicks on the submit button.

我怎样才能做到这一点?

How can I accomplish this?

<一个href="http://www.freeimagehosting.net/%5D%5Bimg=http%3A//www.freeimagehosting.net/uploads/eff1f80752.jpg"相对=nofollow>图片不可用

推荐答案

$ P $从选择一个选项卡pventing用户发出了一个非常直观的用户界面。考虑创建一个向导,一个UI小工具,将用户从一个页面到下一个Next按钮。和一个后退按钮,可选的。你可以说清楚的一个步骤是通过设置Next按钮的Enabled属性完成。

Preventing a user from selecting a tab makes for a very unintuitive user interface. Consider creating a "wizard", a UI gadget that takes the user from one page to the next with a Next button. And a Back button, optional. You can make it clear that a step is completed by setting the Next button's Enabled property.

创建这样一个向导,可以用的TabControl来完成。添加一个新类到您的项目并粘贴下面所示的code。编译。从工具箱顶部的新控件到窗体。在设计时,它看起来像一个正常的TC,允许您添加所需的每个向导步骤的控制。在运行时,标签是隐藏的。实施下一步和后退按钮很简单,只是改变SelectedIndex属性。

Creating such a wizard can be done with a TabControl. Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your form. At design time it looks like a normal TC, allowing you to add the controls needed for each wizard step. At runtime the tabs are hidden. Implementing the Next and Back buttons is simple, just change the SelectedIndex property.

using System;
using System.Windows.Forms;

class WizardPages : TabControl {
  protected override void WndProc(ref Message m) {
    // Hide tabs by trapping the TCM_ADJUSTRECT message
    if (m.Msg == 0x1328 && !DesignMode) m.Result = (IntPtr)1;
    else base.WndProc(ref m);
  }
}

这篇关于控制的WinForms用户的工作流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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