[問題] 開啟 panel 算是觸發控制嗎?
是這樣的,
我做了一個介面,目前是三頁,如圖:
http://ppt.cc/9a73
第一頁是使用者的參數設定,當使用者輸入完參數後,按GO去執行。
第二頁跟第三頁結果頁面。
我目前要先弄懂的部分就是 :按GO是否能把值丟到第二頁去運算
所以我先DEBUG "GO"這顆鈕,
看按下去會不會去做我的test code (單純畫一條線跟輸出一段字)
=================================================
我在button1下的code是 (畫一條斜線跟輸出一段字)
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = "請輸入數字";
Graphics VerticalGrid = this.panel1.CreateGraphics();
Pen bigline = new Pen(Color.Blue, 3);
VerticalGrid.DrawLine(bigline, 50, 50, 100, 100);
}
還沒按GO之前:http://ppt.cc/gIih,框框沒東西 (框框的Name 是 textBox1)
按下GO後卻只有第一行有執行,結果:http://ppt.cc/MW-5
卻沒有畫線,是不是因為我按GO之後,又按了上面的panel(換到第二頁看輸出)
是控制鈕被蓋過去?
因為我又把原本的code 移到 panel下就有了,如圖:http://ppt.cc/GD10
(當我切換到第二頁就會執行這段code吧)
code:
private void panel1_Paint(object sender, PaintEventArgs e)
{
textBox1.Text = "請輸入數字";
Graphics VerticalGrid = this.panel1.CreateGraphics();
Pen bigline = new Pen(Color.Blue, 3);
VerticalGrid.DrawLine(bigline, 50, 50, 100, 100);
}
============================更新============================
之後我在第二頁又新增一個 button,如圖:http://ppt.cc/n~rq
code如下:
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = "請輸入數字";
Graphics VerticalGrid = this.panel1.CreateGraphics();
Pen bigline = new Pen(Color.Blue, 3);
VerticalGrid.DrawLine(bigline, 50, 50, 100, 100);
}
button2 執行前:http://ppt.cc/Bzqf
button2 執行後:http://ppt.cc/Ldih 卻又可以
我要問的問題是:當我按第一頁的GO後(button1)如何切換到第二頁看結果。
也就是執行 button1下的code
(似乎按了第二頁那個動作就把原本的button1蓋過去了)
小弟在這先謝大家。
我是要把原本matlab上的UI介面移植到C#上,所以C#算是剛學。有在K書中
並不是伸手牌。
--
--
▂▂ ▂▂▂
▂▄▅▅▄▆█ _█◣
◢ (●) ◣/\\
丫 │◥  ̄◤
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.20.14
※ 編輯: sqrt1089 來自: 140.116.20.14 (09/09 13:33)
※ 編輯: sqrt1089 來自: 140.116.20.14 (09/09 13:39)
→
09/09 15:12, , 1F
09/09 15:12, 1F
→
09/09 15:12, , 2F
09/09 15:12, 2F
→
09/09 15:16, , 3F
09/09 15:16, 3F
→
09/09 15:17, , 4F
09/09 15:17, 4F
→
09/09 15:19, , 5F
09/09 15:19, 5F