Get value of a dynamic control

M

MounilK

Hi all,
I have a DLL(myLib.dll) in which I have a form (myForm) On
myForm, I have a TabControl (myTabCtrl).
I am creating a new tab-pages on myTabCtrl at runtime as per
the requirements; and on the tab-pages I am adding a DateTimePicker control;
On myForm I also have a command button (cmdClick). After the
user has selected the date on the DateTimePicker control and then clicks
cmdClick,
I want to display a messagebox with the values of each
DateTimePicker on the various tab-pages. How do I do that? Pls help.

Thanking you,
Mounil.
 
T

Tomas Vera

Mounil,
Here is one method that has worked for me.

On myForm, the button has to be accessible to the caller.
Once that is so, then you can simply add an event handler to cmdClick
that will execute in your calling class.

Example:
private void AddControlsToMyForm()
{
MyLib.MyForm myForm;
myForm= new MyLib.MyForm();
myForm.cmdClick.Click +=new EventHandler(cmdClick_Click);
myForm.ShowDialog();
}

private void cmdClick_Click(object sender, EventArgs e)
{
MessageBox.Show("Button handler in Client form");
}

//--- END OF SNIPPET ---

The key is that in MyLib.MyForm cmdClick must be public or have an
Accessor to cmdClick.

I hope I understood your needs. I hope this helps.

-tomas



Hi all,
I have a DLL(myLib.dll) in which I have a form (myForm) On
myForm, I have a TabControl (myTabCtrl).
I am creating a new tab-pages on myTabCtrl at runtime as per
the requirements; and on the tab-pages I am adding a DateTimePicker control;
On myForm I also have a command button (cmdClick). After the
user has selected the date on the DateTimePicker control and then clicks
cmdClick,
I want to display a messagebox with the values of each
DateTimePicker on the various tab-pages. How do I do that? Pls help.

Thanking you,
Mounil.

/*-------------------------------
* Tomas Vera
* tomas (at) sbcglobal (dot) net
*-------------------------------
*/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top