Hey Guys!!!!
I am searching everywhere but i did'nt find actual answer from internet or may b I am wrong..
I am making a program that stores data.. my all program works perfectly but there is one problem
i cannot solve.. i am new to WINDOWS FORM (Object ORIENTED) and i directly jumped from console
version to WINDOWS version.. coming to topic ...
I have LISTBOX1 and EDIT and SAVE button when i select name in List box and press EDIT button
all information is retrieved and set in textboxes.. but i want that the selected name in LISTBOX
make a global variable and so that when i want variable i get from global variable ?? how can i do this
here is my code../
private: System::Void edit_button(System::Object^ sender, System::EventArgs^ e) {
GetData();
}
private: System::Void GetData() {
String^ SelItem;
SelItem = listBox1->SelectedItem->ToString();
StreamReader^ ReadFile = gcnew StreamReader("addressbook.txt");
String^ LineData;
while (ReadFile->Peek() >= 0) {
LineData = ReadFile->ReadLine();
if (LineData->Contains(SelItem) == true)
{
textBox1->Text = LineData->ToString();
LineData = ReadFile->ReadLine();
textBox2->Text= LineData->ToString();
LineData = ReadFile->ReadLine();
textBox3->Text= LineData->ToString();
LineData = ReadFile->ReadLine();
textBox4->Text= LineData->ToString();
LineData = ReadFile->ReadLine();
textBox5->Text= LineData->ToString();
}
}
ReadFile->Close();
}
private: System::Void save_edited(System::Object^ sender, System::EventArgs^ e) {
here i want SelItem how can i get this from edit_button
i dont want listbox1 selected item .. i want SelItem string value that was created in
edit_button ... how can i pass this variable to save_edited button ??
}
Thanks In advance.. and my english is not too much perfect.!!!