如何在Windows窗体中用C#创建弹出窗口? [英] How to create a Popup Window in C# in Windows forms?

查看:71
本文介绍了如何在Windows窗体中用C#创建弹出窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我的问题是如何创建弹出窗口,当我们点击按钮然后弹出窗口闪烁,我们在文本框中输入内容弹出窗口中存在,当我们点击保存时,数据会进入主窗口的文本框中。例如:我想创建一个单位转换器弹出窗口,它将脚转换为mtrs,cms,inch,转换后它会在主窗口上显示的文本框中显示结果。希望你得到我想说的话......

Hi all,

My question is how can be create a Popup window,when we click on a button then popup window is flashed and we enter something in textbox existing in popup and when we click on save the data gets in the textbox of the main window. for example: i want to create a Unit Converter popup which will convert feet into mtrs,cms,inches and after the conversion it show the result in the textbox present on the Main Window.Hope u got what i am trying to say...

推荐答案

假设您调用了弹出窗口类PopupWindow。您通过右键单击项目资源管理器中的项目并选择添加新Windows窗体来创建它。然后你添加了一个文本框和一个Ok-Button。



你还在表单中添加了一个属性,以便以后可以访问用户的数据在文本框中输入。
Let's say you called your popup window class "PopupWindow". You created it by right-clicking on your project in project explorer and chosing "Add new Windows Form". Then you added a text box and an "Ok"-Button.

You also added a property to your form so that you can later gain access to the data the user entered in the text box.
public class PopupWindow
{
    public string EnteredText
    {
        get
        {
            return( textBox.Text );
        }
    }
}

现在你使用这样的新类:

Now you use your new class like this:

PopupWindow popup = new PopupWindow();

popup.ShowDialog();

string userEnteredText = popup.EnteredText;

popup.Dispose();






在您的解决方案中添加新表单,例如按钮点击时的abc



,制作该表格的对象

Hi,

Add new form to your solution,eg Abc

on button click,make an object of that form
Abc a= new Abc();
a.ShowDialog();


我认为我们应该使用vb.net中的弹出控件并显示弹出窗口
I think we should use popup controls from vb.net and show the popup


这篇关于如何在Windows窗体中用C#创建弹出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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