Create buttons in another form

G

Guest

Hello,
I need to add elements out of a function to several forms. Example: I have
three forms, and every form needs a titlebar, wich i have designes as an
image with a frew buttons. I don't want to add the titlebar in everyform, so
i hoped to write a function, wich adds these few elements to the active form
when called.

I hope you understand my question ;o)

Greetings,
Cyberdot
 
D

David D Webb

A form is simply a class derived from Form, so just pass a reference to the
class to the function:

C#:

// Form constructor
public MyForm()
{
SomeClass.UpdateTitle((Form)this, "My Title");
}

public class SomeClass
{
public static void UpdateTitle(Form frm, string title)
{
frm.Text = title;
}
}

-Dave
 

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