0

Hi,

I created two window form (the two form call form1 and blank), when I click a button on the first form it will link to the second form. However, i face problem when I wish to change the second form text (name of the form) using the string I get from combobox. Here is what I wrote:

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
Blank().ShowDialog();
Blank().Text=this->comboBox1->SelectedItem->ToString();
}

Why is it so?? Can someone provide me some advice....PLS and million thanks.

Regards,

Adrian

Edited by happygeek: fixed formatting

2
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by mitrmkar
0

You are misusing the form class, you instantiate two objects of the Blank class in your code.
And you need to set the window text prior to showing the form ...

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

    // A single instance of Blank needed in this function
    Blank BlankFrm;

    // Set the window text before you show the form
    BlankFrm.Text = this->comboBox1->SelectedItem->ToString();

    // then show the form
    BlankFrm.ShowDialog();
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.