.NET C#Windows窗体应用程序:打开弹​​出窗口 [英] .net C# windows Form Application : open popup window

查看:92
本文介绍了.NET C#Windows窗体应用程序:打开弹​​出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Windows窗体应用程序。我想开一个小的文本框在一个窗口中启动该程序中输入用户名或电子邮件。

I am using Windows Form application. I want to open a small textbox on a window to enter user's name or Email in Starting for the program.

我怎样才能做到这一点?

How can I achieve this?

推荐答案

写了一个,这是一件几乎微不足道(创建表单并添加标签,文本框和按钮),并使用VB一个perputating的东西,只投入到安抚并柜暴徒。

Write one, 'tis almost trivial (creating the form and adding label, textbox and buttons) and using the VB one is perputating something that was only put in to appease the baying mob.

主要方法是ShowDialog的(),这是一个表格上的方法。

Key method is ShowDialog() which is a method on a Form.

在表格请确保您设置的确定标志和正确的取消按钮,并提供一个属性(最好),让您阅读(如果有必要写)文本框中

On the form make sure you set the flags for the Ok and Cancel buttons correctly and provide a property (ideally) to allow you to read (and write if necessary) the text box

然后就可以做到大致如下的东西线:

You can then do something along the lines of the following:

using(MyInputForm mif = new MyInputForm)
{
    if (mif.ShowDialog() == DialogResult.OK)
    {
         dataFromDialog = mif.InputData;
    }
    else
    {
         // logic to deal with cancel
    }
}

您可以做在WPF类似的东西,没有一个例子,虽然手。

You can do something similar in WPF, don't have an example to hand though.

这篇关于.NET C#Windows窗体应用程序:打开弹​​出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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