Hi,
You can use custom events to achieve this.
Two forms
frmButtons and frmPicture
Linked as follows.
frmPicture declare a public variable say myButtonForm of type frmButton
frmPicture is start up form
This is just the ground work so that frmPicture can respond to events raised
by frmButton.
Now...On frmButton create custom events that deliver the 'goods'.
Note ButtonEventaAgs class. You can put whatever payload you like into this.
Have the buttons etc on frmButton raise these events with the appropriate
payloads
Write eventhandlers on frmPicture for the events:
Sample Code Follows:
Pushing button on frmButton delivers string payload to frmPicture which
displays it.
HTH
Bob
*************fr mButton **************
namespace TestEvents
{
public partial class frmButton : Form
{
public delegate void ButtonEventHand ler(object sender,ButtonEv entArgs e);
public event ButtonEventHand ler ButtonEvent;
public frmButton()
{
InitializeCompo nent();
}
private void button1_Click(o bject sender, EventArgs e)
{
ButtonEventArgs b = new ButtonEventArgs ();
b.MyProperty = "Payload string";
ButtonEvent(thi s, b);
}
}
}
******frmPictur e************** *
namespace TestEvents
{
public partial class frmPicture : Form
{
public frmButton myForm;
public frmPicture()
{
InitializeCompo nent();
myForm = new frmButton();
myForm.ButtonEv ent += new frmButton.Butto nEventHandler(m yForm_ButtonEve nt);
myForm.Show();
}
void myForm_ButtonEv ent(object sender, ButtonEventArgs e)
{
MessageBox.Show (e.MyProperty);
}
}
}
*************** *******Derived Eveent Arg class********** *********
namespace TestEvents
{
class ButtonEventArgs :System.EventAr gs
{
private String mstrPayload;
public String MyProperty
{
get { return mstrPayload; }
set { mstrPayload = value; }
}
}
}
"pool" <vf********@gma il.com> wrote in message
news:11******** *************@u 72g2000cwu.goog legroups.com...
This has probably been asked before, but I cannot seem to find what i
need with the searches I have tried.
I am trying to learn C# for a project at work that I will probably be
moving on to. I am trying to figure out to create a form which will
interact with a graphics. In other words, I would like to create a form
with buttons and other components on it, and have events from that form
cause stuff to be drawn (lines, arcs, etc) in another form.
If someone could point me to a simple example of this, I would be most
appreciative.
Thanks