Komponentalar
.pdfÁmeliy jumıstı orınlaw
ListBox, ComboBox, ImageList, LinkLabel, GroupBox, Panel
ListBox komponentası
ListBox komponentası
ListBox — bul paydalanıwshıǵa bir neshe elementler dizimin kórsetiw hám sol dizimnen bir yamasa bir neshe elementti saylaw imkaniyatın beriwshi komponenta.
1. ListBox-tıń tiykarǵı qásiyetleri (Properties)
Visual Studio-daǵı Properties aynası arqalı tómendegi qásiyetlerdi basqarıw múmkin:
•Items: Dizim degi elementler toplamı. Bul jerge qatarlardı (string) qosıw arqalı dizimdi toldırasız.
•SelectionMode: Saylaw rejimini belgileydi:
o One: Tek bir elementti saylaw múmkin.
o MultiSimple: Bir neshe elementti tishqansha menen basıw arqalı saylaw múmkin.
oMultiExtended: Shift yamasa Ctrl túymeleri kómeginde bir neshe elementti kompleksli saylaw.
•Sorted: Eger true etip qoyılsa, dizim álipbe boyınsha avtomatikalıq túrde sortlanadı.
•SelectedIndex: Saylanǵan elementtiń tártip nomeri (index). Indekslew 0 den baslanadı. Eger hesh nárse saylanbaǵan bolsa, qásiyet mánisi -1 boladı.
•SelectedItem: Saylanǵan elementtiń tekstli mánisi.
Joybar dizayni (Interface)
Formaǵa tómendegi komponentalardı qoyıń hám olardıń Text qásiyetin ózgertiń:
1.textBox1 (Taza tekst jazıw ushın) 2.listBox1 (Elementler dizimi)
3.button1 (Text: "Qosıw") 4.button2 (Text: "Óshiriw")
5.button3 (Text: "Tazalaw")
6.button4 (Text: "Maǵlıwmat alıw")
7.label1 (Text: "Elementler sanı: 0")
1. Element qosıw (button1)
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
// textBox1 ishinde tekst bar ekenligin tekseremiz if (textBox1->Text != "") {
listBox1->Items->Add(textBox1->Text); // Dizimge qosıw
textBox1->Clear(); |
// |
Maydandı |
tazalaw |
textBox1->Focus(); |
// |
Kurdordı |
textBox-qa qaytarıw |
// Sanawshını jańalaw
label1->Text = "Elementler sanı: " + listBox1->Items->Count.ToString();
}
}
2. Saylanǵan elementti óshiriw (button2)
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
//Dizimnen bir nárse saylanǵan-saylanbaǵanın tekseremiz if (listBox1->SelectedIndex != -1) {
listBox1->Items->RemoveAt(listBox1->SelectedIndex);
// Sanawshını jańalaw
label1->Text = "Elementler sanı: " + listBox1->Items->Count.ToString(); } else {
MessageBox::Show("Óshiriw ushın elementti saylań!");
}
}
3. Dizimdi tolıq tazalaw (button3)
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
listBox1->Items->Clear();
label1->Text = "Elementler sanı: 0";
}
4. Saylanǵan elementti alıw (button4)
private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
if (listBox1->SelectedIndex != -1) {
// Saylanǵan tekst hám onıń indeksin kórsetiw
String^ tekst = listBox1->SelectedItem->ToString(); int indeks = listBox1->SelectedIndex;
MessageBox::Show("Tekst: " + tekst + "\nIndeks (ornı): " + indeks.ToString());
} else {
MessageBox::Show("Dizimnen element saylań!");
}
}
ComboBox komponentası
