Click here to Skip to main content
15,903,385 members
Home / Discussions / C#
   

C#

 
QuestionDatabinding to the correct Row Pin
Drew McGhie15-Jun-06 11:02
Drew McGhie15-Jun-06 11:02 
AnswerRe: Databinding to the correct Row Pin
Drew McGhie15-Jun-06 11:31
Drew McGhie15-Jun-06 11:31 
QuestionFairly easy task (I think), but difficult to explain (plus I'm sort of a newbie) [modified] Pin
ThisIsMyUserName215-Jun-06 10:45
ThisIsMyUserName215-Jun-06 10:45 
AnswerRe: Fairly easy task (I think), but difficult to explain (plus I'm sort of a newbie) Pin
Josh Smith15-Jun-06 11:14
Josh Smith15-Jun-06 11:14 
GeneralRe: Fairly easy task (I think), but difficult to explain (plus I'm sort of a newbie) Pin
ThisIsMyUserName215-Jun-06 11:20
ThisIsMyUserName215-Jun-06 11:20 
GeneralRe: Fairly easy task (I think), but difficult to explain (plus I'm sort of a newbie) Pin
Josh Smith15-Jun-06 11:43
Josh Smith15-Jun-06 11:43 
GeneralRe: Fairly easy task (I think), but difficult to explain (plus I'm sort of a newbie) Pin
ThisIsMyUserName215-Jun-06 12:30
ThisIsMyUserName215-Jun-06 12:30 
AnswerRe: Fairly easy task (I think), but difficult to explain (plus I'm sort of a newbie) Pin
Alexander Wiseman15-Jun-06 11:24
Alexander Wiseman15-Jun-06 11:24 
Here is a possible way to solve your problem.

If you only want one instance of each form open at once, then why do you create a new form each time one of the methods is called? Instead, declare each of the form variables inside your class as private and then when one of the methods is called you can simply create the form if it does not exist already, or if it does exist, then you can simply call a method on it to update its information.

Here is how you would write it:
//Inside Class2:
private MainForm formA;
private MainForm formB;
...
public void ShowA(string defaultValue)
{
     // Create the form if it is not created yet:
     if(formA == null)
     {
          formA = new MainForm();
          formA.DefaultValue = Convert.ToDouble(defaultValue);
          formA.Title = "A";
          formA.picWindow.Paint += new PaintEventHandler(formA.PaintA);
          formA.Show();
     }
     else
     {
          formA.SomeUpdateFunctionWhichYouCreate(defaultValue);
     }
}
Make a method similar for formB. In this way, you won't be creating the form every time and you'll be able to tell the form to update itself via a function that you create on the form.

Hope that helps!


Sincerely,
Alexander Wiseman
GeneralRe: Fairly easy task (I think), but difficult to explain (plus I'm sort of a newbie) Pin
Alexander Wiseman15-Jun-06 11:29
Alexander Wiseman15-Jun-06 11:29 
GeneralRe: Fairly easy task (I think), but difficult to explain (plus I'm sort of a newbie) Pin
ThisIsMyUserName215-Jun-06 12:12
ThisIsMyUserName215-Jun-06 12:12 
GeneralRe: Fairly easy task (I think), but difficult to explain (plus I'm sort of a newbie) Pin
Alexander Wiseman15-Jun-06 12:22
Alexander Wiseman15-Jun-06 12:22 
GeneralRe: Fairly easy task (I think), but difficult to explain (plus I'm sort of a newbie) Pin
ThisIsMyUserName215-Jun-06 12:39
ThisIsMyUserName215-Jun-06 12:39 
GeneralRe: Fairly easy task (I think), but difficult to explain (plus I'm sort of a newbie) Pin
Alexander Wiseman15-Jun-06 12:47
Alexander Wiseman15-Jun-06 12:47 
GeneralRe: Fairly easy task (I think), but difficult to explain (plus I'm sort of a newbie) Pin
ThisIsMyUserName215-Jun-06 13:21
ThisIsMyUserName215-Jun-06 13:21 
QuestionUsing RPC (with IDL) from C# Pin
BambooMoon15-Jun-06 9:55
BambooMoon15-Jun-06 9:55 
QuestionDataGridView custom Column Pin
Mike0915-Jun-06 8:56
Mike0915-Jun-06 8:56 
Questiondatagrid and databinding (long due to code) Pin
leckey15-Jun-06 8:51
leckey15-Jun-06 8:51 
AnswerRe: datagrid and databinding (long due to code) Pin
Josh Smith15-Jun-06 9:18
Josh Smith15-Jun-06 9:18 
QuestionSending info to command line Pin
ddpn4215-Jun-06 8:47
ddpn4215-Jun-06 8:47 
AnswerRe: Sending info to command line Pin
Alexander Wiseman15-Jun-06 8:54
Alexander Wiseman15-Jun-06 8:54 
GeneralRe: Sending info to command line Pin
Josh Smith15-Jun-06 9:02
Josh Smith15-Jun-06 9:02 
GeneralRe: Sending info to command line [modified] Pin
ddpn4215-Jun-06 9:21
ddpn4215-Jun-06 9:21 
GeneralRe: Sending info to command line Pin
Alexander Wiseman15-Jun-06 9:25
Alexander Wiseman15-Jun-06 9:25 
GeneralRe: Sending info to command line Pin
ddpn4215-Jun-06 10:02
ddpn4215-Jun-06 10:02 
GeneralRe: Sending info to command line Pin
Dustin Metzgar15-Jun-06 10:15
Dustin Metzgar15-Jun-06 10:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.