Click here to Skip to main content
15,895,084 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to get errors number in sqlserver from C# Pin
superdragon9-Apr-06 18:36
superdragon9-Apr-06 18:36 
QuestionPlz Help me with these two problems !!! Pin
mrkeivan8-Apr-06 9:06
mrkeivan8-Apr-06 9:06 
AnswerRe: Plz Help me with these two problems !!! Pin
Ed.Poore8-Apr-06 9:14
Ed.Poore8-Apr-06 9:14 
GeneralRe: Plz Help me with these two problems !!! Pin
mrkeivan8-Apr-06 10:23
mrkeivan8-Apr-06 10:23 
AnswerRe: Plz Help me with these two problems !!! Pin
Guffa8-Apr-06 11:08
Guffa8-Apr-06 11:08 
GeneralRe: Plz Help me with these two problems !!! Pin
Ed.Poore8-Apr-06 12:20
Ed.Poore8-Apr-06 12:20 
GeneralRe: Plz Help me with these two problems !!! Pin
mrkeivan8-Apr-06 18:04
mrkeivan8-Apr-06 18:04 
GeneralRe: Plz Help me with these two problems !!! Pin
Ed.Poore8-Apr-06 21:44
Ed.Poore8-Apr-06 21:44 
mrkeivan wrote:
OK this code should be in my first form as a property, right ?


This code should be in the form which you are using to display the value, i.e. not the one with the property you're trying to access.

private Form1 f = new Form1();
public Form1 Form {
  get {
    return this.f;
  }
}


This is a property definition, it defines a property called Form with type Form1 (i.e. your form). You cannot have a variable inside the get {...} construct otherwise it will be re-initialised everytime you access the property. Hence the private Form1 f declaration outside the property definition, this only creates a Form1 object once when the variable is initialised and then you can access this variable through the Form property (to get the number property you want.

NB: If you are doing the following:
One form (the "master" form) is in control of displaying the second ("input") and you want the master form to display the number property of the input form then you can do the following which is slightly simpler:

public class MasterForm : Form {
  private Form1 inputForm = new Form1();

  // This is just an example function, you'd put the code from here
  // into you're event handler / whatever function you use to display
  // the code.
  public void DisplayNumber() {
    MessageBox.Show(this.inputForm.number.ToString());
  }
}


This code ensures that by having the variable declared as global to the functions etc inside the MasterForm, the second Form1 is only created once.

Ed
Questioncreating a db file with thumbnails, how to? Pin
finskiy8-Apr-06 6:45
finskiy8-Apr-06 6:45 
AnswerRe: creating a db file with thumbnails, how to? Pin
CWIZO9-Apr-06 2:44
CWIZO9-Apr-06 2:44 
GeneralRe: creating a db file with thumbnails, how to? Pin
finskiy9-Apr-06 7:22
finskiy9-Apr-06 7:22 
GeneralRe: creating a db file with thumbnails, how to? Pin
CWIZO9-Apr-06 9:39
CWIZO9-Apr-06 9:39 
GeneralRe: creating a db file with thumbnails, how to? Pin
finskiy9-Apr-06 12:52
finskiy9-Apr-06 12:52 
GeneralRe: creating a db file with thumbnails, how to? Pin
CWIZO9-Apr-06 20:29
CWIZO9-Apr-06 20:29 
Questionhow to update view in net.2 Pin
papa19808-Apr-06 4:23
papa19808-Apr-06 4:23 
AnswerRe: how to update view in net.2 Pin
CWIZO8-Apr-06 5:20
CWIZO8-Apr-06 5:20 
QuestionWeb Service Access Pin
AB77717-Apr-06 23:53
AB77717-Apr-06 23:53 
QuestionAttributes displaying lists Pin
MBursill7-Apr-06 23:08
MBursill7-Apr-06 23:08 
QuestionOutOfMemeryException happens in Grphics method Pin
SharpShark7-Apr-06 22:12
SharpShark7-Apr-06 22:12 
Questionurgent----how to get date format like dd/mm/yy Pin
madhu1437-Apr-06 21:37
madhu1437-Apr-06 21:37 
AnswerRe: urgent----how to get date format like dd/mm/yy Pin
Guffa7-Apr-06 22:06
Guffa7-Apr-06 22:06 
GeneralRe: urgent----how to get date format like dd/mm/yy Pin
Colin Angus Mackay7-Apr-06 23:54
Colin Angus Mackay7-Apr-06 23:54 
GeneralRe: urgent----how to get date format like dd/mm/yy Pin
George L. Jackson8-Apr-06 1:20
George L. Jackson8-Apr-06 1:20 
GeneralRe: urgent----how to get date format like dd/mm/yy Pin
Colin Angus Mackay8-Apr-06 1:25
Colin Angus Mackay8-Apr-06 1:25 
GeneralRe: urgent----how to get date format like dd/mm/yy Pin
George L. Jackson8-Apr-06 1:54
George L. Jackson8-Apr-06 1:54 

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.