第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何從文本框中獲取文本到 C# 中的 Button 事件

如何從文本框中獲取文本到 C# 中的 Button 事件

C#
侃侃爾雅 2022-01-16 15:09:02
我已經(jīng)創(chuàng)建了這段代碼在 .dll 文件中創(chuàng)建表單并添加控件        TextBox dbname = new TextBox();          dbname.BorderStyle = BorderStyle.Fixed3D;        dbname.Location = new Point(236, 81);        Button Create = new Button();        Create.FlatStyle = FlatStyle.Flat;        Create.FlatAppearance.BorderSize = 0;        Create.Location = new Point(261, 115);        Create.Text = "Create";        Create.Click += new System.EventHandler(this.Create_Click);如何從文本框中獲取文本?private void Create_Click(object sender , EventArgs e)    {        SaveFileDialog _sfd_ = new SaveFileDialog();        _sfd_.Filter = "Housam Printing |*.HP";        _sfd_.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;        _sfd_.FileName = dbname.text;        _sfd_.Title = "Database location";    }
查看完整描述

1 回答

?
POPMUISE

TA貢獻(xiàn)1765條經(jīng)驗(yàn) 獲得超5個(gè)贊

為了使您的控件可供類的其他成員訪問(wèn),您需要在類級(jí)別定義它們。Form_Load然后您可以在構(gòu)造函數(shù)或事件(或任何您想要的地方)中初始化它們,并可以從其他類方法訪問(wèn)它們:


public partial class Form1 : Form

{

    // Declare your controls at the class level so all methods can access them

    private TextBox dbName;

    private Button create;


    private void Form1_Load(object sender, EventArgs e)

    {

        dbName = new TextBox

        {

            BorderStyle = BorderStyle.Fixed3D,

            Location = new Point(236, 81)

        };

        Controls.Add(dbName);


        create = new Button

        {

            FlatStyle = FlatStyle.Flat,

            Location = new Point(261, 115),

            Text = "Create",

        };

        create.FlatAppearance.BorderSize = 0;

        create.Click += create_Click;

        Controls.Add(create);

    }


    private void create_Click(object sender , EventArgs e)

    {

        var sfd = new SaveFileDialog

        {

            Filter = "Housam Printing |*.HP",

            InitialDirectory = AppDomain.CurrentDomain.BaseDirectory,

            FileName = dbName.Text,

            Title = "Database location"

        };

    }

}        


查看完整回答
反對(duì) 回復(fù) 2022-01-16
  • 1 回答
  • 0 關(guān)注
  • 207 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)