Re: [問題] 自訂函數的參數有控制項
還好還記得 XD
在 .h 有宣告的元件 (也就是用拉的)
TListBox *ListBox1;
可以在 .cpp 的 Form1 直接用 (也就是不用傳入參數)
因為 ListBox1 是那個類別裡的東西.
找一個 button 去加一些資料到 ListBox1, 就像這樣寫:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
ListBox1->Items->Add("Chad");
ListBox1->Items->Add("Equatorial Guinea");
ListBox1->Items->Add("Egypt");
ListBox1->Items->Add("Madagascar");
ListBox1->ItemIndex = ListBox1->Items->Count-1;
}
另外, 自己去 new 的 TListBox, 就要這麼寫 (綁在另一個button上):
void __fastcall TForm1::Button2Click(TObject *Sender)
{
TListBox *ListBox2 = new TListBox(Sender);
ListBox2->Parent = Form1;
// 其他的屬性(Left/Top/...)自己再加上去
}
試出來可以用. 但不知有沒有side-effect.
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.117.176.153
→
09/29 20:48, , 1F
09/29 20:48, 1F
→
09/29 20:48, , 2F
09/29 20:48, 2F
推
09/29 20:50, , 3F
09/29 20:50, 3F
→
09/29 20:50, , 4F
09/29 20:50, 4F
→
09/29 21:02, , 5F
09/29 21:02, 5F
→
09/29 21:03, , 6F
09/29 21:03, 6F
推
09/29 22:00, , 7F
09/29 22:00, 7F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 3 篇):
1
3
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章
11
38