Multiple .cs files using shared method, using form name as a parameter
Take a look at this basic example:
public static void headbar(string formname, string heading)
{
string oldheading;
oldheading=formname.Text;
formname.Text=oldheading+" "+heading;
}
Then when I initiate a form (say "myform"), I would:
headbar("myform","testing");
The intended functionality here is to have this common method be used to add verbiage to the .Text property of a form, where I'm providing the form name as a parameter. (There is a 'bigger' issue at stake, but this simple example illustrates what I don't know how to accomplish). The code above won't compile, because "Text" is not a property of the string variable "formname". But the contents of "formname" would have a "Text" property. How would I change my code above to work as intended?

Roei BarRank #1,271 · 1.4K reputationPosted Oct 6, 2009, 11:45 AM EDT
public static void headbar(ref Form formname, string heading) { string oldheading; oldheading = formname.Text; formname.Text = oldheading + " " + heading; }Mike Pischke11 reputationPosted Oct 6, 2009, 11:27 AM EDT
Mike Pischke11 reputationPosted Oct 7, 2009, 7:45 AM EDT
Mike Pischke11 reputationPosted Oct 7, 2009, 7:59 AM EDT