TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
lumumba14
NA
4
0
Copying a control to a new form
Jun 30 2004 6:31 AM
Hello, I am using a grid control in a form which displays some data to the user. I have added some code to its Click event, which displays some data from this control to textboxes in the new form. The data is passed to the new form through its constructor and it works ok. But then I want to pass the complete control from the first form to the second, along with its data, again through the second form's constructor. The control is passed, it is displayed ok, but it is lost from the main form. Here is what I do: class FirstClass : System.Windows.Forms.Form { //... private void grid_Click(object sender, EventArgs e) { SecondClass newOne = new SecondClass(txt, grid); newOne.Show(); //the SecondClass form displays ok } } class SecondClass : System.Windows.Forms.Form { //.. private Grid theGrid; private string theString; public SecondClass(string txt, Grid grid) { // //this is the second constructor of the second class // InitializeComponent(); theGrid = grid; theString = txt; } private void SecondClass_Load(object sender, EventArgs e) { txtBox1.Text = txt; //works fine this.Controls.Add(theGrid); //works fine, the grid is displayed ok with all the data //from the first form, but it is lost from the first form } }//end SecondClass Still haven't found a solution, could anyone help me with this problem?
Reply
Answers (
2
)
MDI applications
How to "call" and event