tbmvp

I have a main form with a listview control docked in it, and there is another form in my application include an left button which named "Done". I want to know: when i click the "Done" button, i use "this.close()" code to close the form, but i also want to add some items to the listview control which in the main form and then display them.

Should i use the SendMessage() method or anything else

Can anybody tell me how i can do it, please

thanks.


Re: Smart Devices VB and C# Projects How can i send a message from one form to another form(smartphone)

Christopher Fairbairn

Hi,

There are a number of possible ways to implement this depending upon your needs. One possible technique (if using modal dialogs) would be to expose the information you need to pass back via properties on your second form.

An outline of how that may look in code is as follows:

public class FormWithListView : Form

{

public void ShowDetailsForm()

{

DetailsForm f = new DetailsForm();

f.ShowDialog();

// You could replace this message box with something which

// altered your list view control

MessageBox.Show(f.ExampleValue, "Value from details form");

}
}

public class DetailsForm : Form

{

private void Done_Click(object sender, EventArgs e)

{

Close();

}

public string ExampleValue

{

get { return textBox1.Text; }

}
}

If you simply need access to a textbox or similiar control within the second form, you could also just set the "Modifiers" property of the control you want to access to "Public".

Hope this helps,

Christopher Fairbairn






Re: Smart Devices VB and C# Projects How can i send a message from one form to another form(smartphone)

tbmvp

Hi,nice man.

I tried your method in my application, and it works.

Thanks for your help, i think i will use it as a nice tip in the other applications.