<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                1、點擊button按鈕,選中“屬性”中的閃電標志,輸入click的動作名字(假如命名為OnClick), ![](https://ws3.sinaimg.cn/large/006tKfTcgy1fr1dvszv7oj30n50cognn.jpg) 2、雙擊click處,在彈出的`Form1.cs`中輸入以下第三行代碼。得到如圖結果。 ``` private void OnClick(object sender, EventArgs e) { MessageBox.Show("確認提交", "應用程序", MessageBoxButtons.OK, MessageBoxIcon.Information); } ``` ![](https://ws3.sinaimg.cn/large/006tKfTcgy1fr1dw9y9hqj30l908zt95.jpg) 3、在app中,默認中 `Program.cs`中的`static void Main()`開始運行。所以如果要更換啟動窗口,則可以在該位置更換其他窗口form的名字。 ![](https://ws3.sinaimg.cn/large/006tKfTcgy1fr1dwn2qydj30md0c2mz6.jpg) 4、需要注意的是,上述動作被記錄在`Form1.cs`文件中的 `private void InitializeComponent()`中,不要隨意改動。 5、同一個窗體應用中要設置先啟動哪一個?: 啟動窗體 比如在EMS-windows-app這個應用中,有很多窗體,想先啟動“審核登記”。這時候找到 EMS-windows-app 里面的 Program.cs,修改其中的代碼, 改成“new 審核登記()”即可: `Application.Run(new 審核登記( ) );` ![](https://ws3.sinaimg.cn/large/006tKfTcgy1fs819n5q54j305n0850t5.jpg) ![](https://ws3.sinaimg.cn/large/006tKfTcgy1fs818jnn87j30n509ywgi.jpg) # 設置窗體屬性 ![](https://ws4.sinaimg.cn/large/006tNc79gy1fs1s3z1zxlj30fv07g0ta.jpg) # 5、form 窗體是一個對象,所以在編輯按鈕時,需要創建對象。 # 窗體事件 ![](https://ws4.sinaimg.cn/large/006tNc79gy1fs1tj5usqlj30hj07ugm9.jpg) ## 父窗體、子窗體 也就是單擊打開第二個窗體以后第二個窗體總在第一個窗體內顯示 父窗體:`isMdiContainer` 屬性為 true 即可。 子窗體:父窗體設置完成后,“屬性”中無法直接設置子窗體,需要通過編寫代碼設置`MdiParent`屬性。代碼: ``` Form2 frm2 = new Form2(); frm2.Show(); //顯示窗體 frm2.MdiParent = this; //注意不要寫成midparent ``` ## 平鋪窗口: ``` layoutMdi( Mdilayout. ) ``` arrangelcons => cascade => titlehorizontal => 水平平鋪 titlevertical => 垂直平鋪 ## button 控件點擊后生成新 txt 輸入框: ``` private void button1_Click_1(object sender, EventArgs e)//用于點擊時生成一個txt框 { TextBox txt = new TextBox(); //創建對象txt txt.Location = new Point(0, 0);//初始化坐標位置 this.Controls.Add(txt); // this.Controls指的是button這個控件,觸發的事件是add新增 } ``` ## TextBox 控件 只讀文本、密碼、多行 ![](https://ws2.sinaimg.cn/large/006tNc79gy1fs2ahl9ppdj30g6073dgo.jpg) 默認只能水平改變大小,這時候把multiline屬性設置為 true(多行),即可垂直方向改變大小。 passwordChart屬性中,可以將輸入的密碼顯示成**星號。 可以直接拖動創建,也可以寫代碼: ``` private void button1\_Click(object sender, EventArgs e) { TextBox txt = new TextBox(); this.Controls.Add(txt); //this.control的意思是,這個 button 控件中添加。 } ``` ![](https://box.kancloud.cn/80cb3bc52e9f0ca15064e037d5d912ba_394x254.png) ## radioButton 單選。一般用 check 屬性: ![](https://ws1.sinaimg.cn/large/006tNc79gy1fs2b9a2zuqj30gs07raas.jpg) ``` private void radioButton_admin_CheckedChanged(object sender, EventArgs e) { if(radioButton_admin.Checked) { MessageBox.Show ("以管理員身份登錄"); } } ``` ![](https://ws2.sinaimg.cn/large/006tNc79gy1fs2b72y63jj30mk07tjsb.jpg) ## checkBox 復選 ![](https://ws3.sinaimg.cn/large/006tNc79gy1fs2b9xzmtdj30f006yaak.jpg) ## Rich TextBox——超鏈接 > 如果要設置 richtextbox 控件的字體樣式等,可以在 form 窗口的 load 中編寫代碼。 ![](https://ws4.sinaimg.cn/large/006tKfTcgy1fs4qsh71a7j30jn086mye.jpg) 滾動條、字體屬性、超鏈接、段落格式 ### 1、設置字體樣式 ``` private void 審核意見richTextBox1_TextChanged(object sender, EventArgs e) { 審核意見richTextBox1.SelectionFont = new Font("宋體", 15, FontStyle.Bold); 審核意見richTextBox1.SelectionColor = Color.Red; } ``` ### 2、設置超鏈接 在 richtextbox (這個名字是控件的名字)中輸入以下代碼: ``` richtextbox.Text = "http://www.baidu.com"; ``` 在轉到屬性-事件中,找到 LinkClicked,雙擊,再輸入以下代碼: ``` System.Diagnostics.Process.Start(e.LinkText); // 該命名空間是系統設置好的 ``` ![](https://ws2.sinaimg.cn/large/006tKfTcly1fs4s4e8kimj30iu08y754.jpg) ![](https://ws2.sinaimg.cn/large/006tKfTcgy1fs4scn9eszj30f707mq3c.jpg) ## comboBox控件 dropdownStyle屬性 selectedValueChanged事件 ![](https://box.kancloud.cn/8903cbb5482320190b55961c8fabbf38_551x256.png) 錯誤: 若輸入`messageBox.Show(comboBox1. selectedItem)`; 參數1:無法從“object”轉換為“string”。可直接改成: `MessageBox.Show("崗位:" + comboBox1.SelectedItem);` 即可。 ## listBox ![](https://box.kancloud.cn/294217d09eed895d13f7d7686888fd40_694x340.png) listBox.items.add 屬性 listBox.items.remove 屬性 selectionMode: one \ multisimple \ multiextended ( 意思是用戶可以用 shift 或 control 鍵盤來選中) ## GroupBox 分組 將“密碼、登錄、退出”等直接拖動到新建的“系統登錄”框中,就變成一個組了。 ![](https://box.kancloud.cn/f9e21e77c3d097d188d3e185bfa761ef_474x181.png) ![](https://box.kancloud.cn/96bba143e314a99bb019354e3ce36196_658x432.png) ## listview 列表試圖空間。用于顯示帶圖標的項的列表。類似 windows 資源管理器右邊窗口的用戶界面。 ![](https://box.kancloud.cn/007b2db26e2d1731f46ce8b20c808092_609x288.png) 其中smallimagelist、largeimagelist、stageimagelist屬性與imageList 組件——圖片存儲 一起搭配使用。 ![](https://box.kancloud.cn/3568671113276a57c530b5b9ef3fc842_803x412.png) 直接在items里面添加圖片即可。 先設置group屬性,然后雙擊 form 窗口,在 load 里面添加代碼。 ![](https://box.kancloud.cn/78e531cffddbd3b2a84aee292c453095_648x251.png) 代碼如下:將設置好的組件里面的元素進行分類。 ![](https://box.kancloud.cn/4f1f1937c34f43a83ef935af8daf7f5d_817x468.png) ## treeview控件 樹形結構 ### 新建元素 ![](https://ws3.sinaimg.cn/large/006tNc79gy1fs9ycfsiafj30fg068js1.jpg) 可直接在屬性中設置,也可以在 form 窗口的 load 代碼區輸入: 新建對象 ``` private void 審核登記_Load_1(object sender, EventArgs e) { TreeNode tr1 = treeView1.Nodes.Add("總工辦"); } ``` 刪除的話,可以用 remove。 ### 獲取信息: 雙擊控件,在afterSelect 中輸入 ``` MessageBox.Show(e.Node.Text); //這里的 e 就是上一行的 e ``` ![](https://ws2.sinaimg.cn/large/006tNc79gy1fs9yr2l6e6j30jk08hq3m.jpg) > node其實就是屬性中的 Nodes(如圖1)。點擊后進行Node相關設置,如圖2。所以如果將代碼中的 Node.Text 換成 Node.Tag,則會顯示我們在 Tag 中填入的“備注”(如圖3)。 >![](https://ws1.sinaimg.cn/large/006tNc79gy1fs9yzop6nqj30nl0ao0uj.jpg) > >![](https://ws1.sinaimg.cn/large/006tNc79gy1fs9z0m359rj30k60dh0ub.jpg) > >![](https://ws2.sinaimg.cn/large/006tNc79gy1fs9z3is5h8j30il08odgi.jpg) ### 添加圖標: imageList屬性設置為 true。然后與imageList組件配合。 ## Timer組件 計時器,時間間隔以interval屬性定義,以毫秒為單位。 ![](https://ws4.sinaimg.cn/large/006tNc79gy1fs9za8qi4qj30io09575q.jpg) Enabled 與 start 和 stop 互相替換。enable 為 true,就等于 start。 ![](https://ws1.sinaimg.cn/large/006tNc79gy1fs9zciif91j30dy0870t4.jpg) ![](https://ws3.sinaimg.cn/large/006tNc79gy1fsbklgz75pj30mt0esac9.jpg) ![](https://ws4.sinaimg.cn/large/006tNc79gy1fsbkm7i972j30tb0c20ur.jpg) ## menustrip ![](https://ws2.sinaimg.cn/large/006tNc79gy1fsbpbk086lj30gz07qmxu.jpg) 菜單欄。如果要設置“文件”快捷菜單,在屬性=>text => “文件(&F)”即可。 ![](https://box.kancloud.cn/a1e0b77eb8444f55225e1605d30549ef_243x366.png) ## toolstrip 工具欄。默認添加到 menustrip 下面。 可以顯示圖標和可以顯示文字,右擊,在 display 選項中進行設置。 ![](https://ws2.sinaimg.cn/large/006tNc79gy1fsbpnpdra9j30ff0753yy.jpg) ![](https://ws2.sinaimg.cn/large/006tNc79gy1fsbpkzfg7zj30cd0c9gmv.jpg) ## statusStrip 狀態欄。 ![](https://ws4.sinaimg.cn/large/006tNc79gy1fsbpnwkabzj30g007i0t6.jpg) 比如添加時間:在 form 窗體的 load 語句中,添加: ``` toolStripStatusLabel1.Text = dateTime.Now.ToString(); ``` ![](https://ws2.sinaimg.cn/large/006tNc79gy1fsbpyv8x5oj30dy09gaas.jpg) ## 消息框 messagebox 可以通過提示來一步步設置。 ![](https://ws2.sinaimg.cn/large/006tNc79gy1fsbqbcxj9rj30k00720tu.jpg) ## 打開對話框 控件 openFileDialog 指定打開位置:`openFileDialog.InitialDirectory = "C:\\";` 指定文件類型:`openFileDialog.Filter = "文本文件(*.txt)|*.txt|Word文件(*.doc)|*.doc"` 若要所有格式:`openFileDialog.Filter = "所有文件(*.*)|*.*"` ![](https://ws2.sinaimg.cn/large/006tNc79gy1fsjkoy5s72j30jc09m75f.jpg) ![](https://ws1.sinaimg.cn/large/006tNc79gy1fsjl0t2o31j30fb063js9.jpg) > 最后記得寫上 openFile.Dialog.ShowDialog(); ## 另存為對話框 控件 saveFileDialog 同上 ![](https://ws2.sinaimg.cn/large/006tNc79gy1fsjkrj613mj30ik08k753.jpg) ## 瀏覽文件夾 控件 foldBrowserDialog ![](https://ws1.sinaimg.cn/large/006tNc79gy1fsjl5l86rgj30j0098js8.jpg) `textBox.Text = folderBrowserDialog1.SelectedPath;` # 使用右擊快捷鍵功能 添加contextMenustrip 控件,并在 datagridview 的屬性中把contextmenustrip控件關聯上。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看