Click here to Skip to main content
15,898,996 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to implement IDocHostUIHandler with c# ? Pin
LongRange.Shooter24-Feb-04 11:00
LongRange.Shooter24-Feb-04 11:00 
GeneralRe: How to implement IDocHostUIHandler with c# ? Pin
benzite24-Feb-04 14:37
benzite24-Feb-04 14:37 
GeneralRe: How to implement IDocHostUIHandler with c# ? Pin
Heath Stewart25-Feb-04 2:40
protectorHeath Stewart25-Feb-04 2:40 
GeneralWithout a RDBMS or XML Pin
Sheriff Botros23-Feb-04 18:52
Sheriff Botros23-Feb-04 18:52 
GeneralRe: Without a RDBMS or XML Pin
Mazdak24-Feb-04 3:26
Mazdak24-Feb-04 3:26 
GeneralRe: Without a RDBMS or XML Pin
Heath Stewart24-Feb-04 4:37
protectorHeath Stewart24-Feb-04 4:37 
GeneralRe: Without a RDBMS or XML Pin
Nemanja Trifunovic24-Feb-04 6:23
Nemanja Trifunovic24-Feb-04 6:23 
GeneralQualifying Static Members With Type Names Pin
Eric Houser23-Feb-04 16:15
Eric Houser23-Feb-04 16:15 
When I try to compile my application it always displays the error message, "Static Member '(control)' cannot be referenced with an instant reference; qualify it with a type name instead." I access most of my controls that are on this form from other forms, so at the beginning of the class when all of the controls are declared as private automatically, I changed them to public static.

I Changed This:
private System.Windows.Forms.PictureBox pboBoard;
private System.Windows.Forms.MainMenu mnu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem menuItem7;
private System.Windows.Forms.Label lbl4;
private System.Windows.Forms.PictureBox pboP1;
private System.Windows.Forms.PictureBox pboP2;
private System.Windows.Forms.Button cmd1;
private System.Windows.Forms.Label lbl1;
private System.Windows.Forms.Label lbl2;

To This:
public static System.Windows.Forms.PictureBox pboBoard;
public static System.Windows.Forms.MainMenu mnu1;
public static System.Windows.Forms.MenuItem menuItem1;
public static System.Windows.Forms.MenuItem menuItem2;
public static System.Windows.Forms.MenuItem menuItem3;
public static System.Windows.Forms.MenuItem menuItem4;
public static System.Windows.Forms.MenuItem menuItem5;
public static System.Windows.Forms.MenuItem menuItem6;
public static System.Windows.Forms.MenuItem menuItem7;
public static System.Windows.Forms.Label lbl4;
public static System.Windows.Forms.PictureBox pboP1;
public static System.Windows.Forms.PictureBox pboP2;
public static System.Windows.Forms.Button cmd1;
public static System.Windows.Forms.Label lbl1;
public static System.Windows.Forms.Label lbl2;

Now, there is no problem with the outside access of these controls, but when the components are initialized, it doesn't recognize the reference, "this". The only thing I could think of was changing, "this" to, "Form1"

I Changed This:
public void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.pboBoard = new System.Windows.Forms.PictureBox();
this.mnu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.menuItem7 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.lbl4 = new System.Windows.Forms.Label();
this.pboP1 = new System.Windows.Forms.PictureBox();
this.pboP2 = new System.Windows.Forms.PictureBox();
this.cmd1 = new System.Windows.Forms.Button();
this.lbl1 = new System.Windows.Forms.Label();
this.lbl2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// pboBoard
//
this.pboBoard.Image = ((System.Drawing.Bitmap)(resources.GetObject("pboBoard.Image")));
this.pboBoard.Location = new System.Drawing.Point(-8, -8);
this.pboBoard.Name = "pboBoard";
this.pboBoard.Size = new System.Drawing.Size(584, 544);
this.pboBoard.TabIndex = 0;
this.pboBoard.TabStop = false;
//
// mnu1
//
this.mnu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem2});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem4,
this.menuItem5,
this.menuItem6,
this.menuItem7});
this.menuItem1.Text = "&File";
//
// menuItem4
//
this.menuItem4.Index = 0;
this.menuItem4.Text = "&New Game";
//
// menuItem5
//
this.menuItem5.Index = 1;
this.menuItem5.Text = "&Start Level";
//
// menuItem6
//
this.menuItem6.Index = 2;
this.menuItem6.Text = "-";
//
// menuItem7
//
this.menuItem7.Index = 3;
this.menuItem7.Text = "E&xit";
//
// menuItem2
//
this.menuItem2.Index = 1;
this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem3});
this.menuItem2.Text = "&Help";
//
// menuItem3
//
this.menuItem3.Index = 0;
this.menuItem3.Text = "&About...";
//
// lbl4
//
this.lbl4.BackColor = System.Drawing.Color.Black;
this.lbl4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.lbl4.Font = new System.Drawing.Font("Desdemona", 20.25F);
this.lbl4.ForeColor = System.Drawing.Color.White;
this.lbl4.Location = new System.Drawing.Point(8, 64);
this.lbl4.Name = "lbl4";
this.lbl4.Size = new System.Drawing.Size(528, 40);
this.lbl4.TabIndex = 1;
this.lbl4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// pboP1
//
this.pboP1.Image = ((System.Drawing.Bitmap)(resources.GetObject("pboP1.Image")));
this.pboP1.Location = new System.Drawing.Point(16, 168);
this.pboP1.Name = "pboP1";
this.pboP1.Size = new System.Drawing.Size(35, 50);
this.pboP1.TabIndex = 2;
this.pboP1.TabStop = false;
//
// pboP2
//
this.pboP2.Image = ((System.Drawing.Bitmap)(resources.GetObject("pboP2.Image")));
this.pboP2.Location = new System.Drawing.Point(496, 416);
this.pboP2.Name = "pboP2";
this.pboP2.Size = new System.Drawing.Size(35, 50);
this.pboP2.TabIndex = 3;
this.pboP2.TabStop = false;
//
// cmd1
//
this.cmd1.Enabled = false;
this.cmd1.Font = new System.Drawing.Font("Desdemona", 36F, System.Drawing.FontStyle.Bold);
this.cmd1.Location = new System.Drawing.Point(0, 256);
this.cmd1.Name = "cmd1";
this.cmd1.Size = new System.Drawing.Size(152, 104);
this.cmd1.TabIndex = 4;
this.cmd1.Text = "Start";
//
// lbl1
//
this.lbl1.AutoSize = true;
this.lbl1.Font = new System.Drawing.Font("Desdemona", 26.25F);
this.lbl1.Location = new System.Drawing.Point(160, 160);
this.lbl1.Name = "lbl1";
this.lbl1.Size = new System.Drawing.Size(0, 41);
this.lbl1.TabIndex = 5;
//
// lbl2
//
this.lbl2.AutoSize = true;
this.lbl2.Font = new System.Drawing.Font("Desdemona", 26.25F);
this.lbl2.Location = new System.Drawing.Point(72, 432);
this.lbl2.Name = "lbl2";
this.lbl2.Size = new System.Drawing.Size(0, 41);
this.lbl2.TabIndex = 6;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.Color.Black;
this.ClientSize = new System.Drawing.Size(544, 529);
this.ControlBox = false;
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.lbl2,
this.lbl1,
this.cmd1,
this.pboP2,
this.pboP1,
this.lbl4,
this.pboBoard});
this.ForeColor = System.Drawing.Color.White;
this.Menu = this.mnu1;
this.Name = "Form1";
this.Text = "Elicit Response";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);

To This:
public void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
Form1.pboBoard = new System.Windows.Forms.PictureBox();
Form1.mnu1 = new System.Windows.Forms.MainMenu();
Form1.menuItem1 = new System.Windows.Forms.MenuItem();
Form1.menuItem4 = new System.Windows.Forms.MenuItem();
Form1.menuItem5 = new System.Windows.Forms.MenuItem();
Form1.menuItem6 = new System.Windows.Forms.MenuItem();
Form1.menuItem7 = new System.Windows.Forms.MenuItem();
Form1.menuItem2 = new System.Windows.Forms.MenuItem();
Form1.menuItem3 = new System.Windows.Forms.MenuItem();
Form1.lbl4 = new System.Windows.Forms.Label();
Form1.pboP1 = new System.Windows.Forms.PictureBox();
Form1.pboP2 = new System.Windows.Forms.PictureBox();
Form1.cmd1 = new System.Windows.Forms.Button();
Form1.lbl1 = new System.Windows.Forms.Label();
Form1.lbl2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// pboBoard
//
Form1.pboBoard.Image = ((System.Drawing.Bitmap)(resources.GetObject("pboBoard.Image")));
Form1.pboBoard.Location = new System.Drawing.Point(-8, -8);
Form1.pboBoard.Name = "pboBoard";
Form1.pboBoard.Size = new System.Drawing.Size(584, 544);
Form1.pboBoard.TabIndex = 0;
Form1.pboBoard.TabStop = false;
//
// mnu1
//
Form1.mnu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
Form1.menuItem1,
Form1.menuItem2});
//
// menuItem1
//
Form1.menuItem1.Index = 0;
Form1.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
Form1.menuItem4,
Form1.menuItem5,
Form1.menuItem6,
Form1.menuItem7});
Form1.menuItem1.Text = "&File";
//
// menuItem4
//
Form1.menuItem4.Index = 0;
Form1.menuItem4.Text = "&New Game";
//
// menuItem5
//
Form1.menuItem5.Index = 1;
Form1.menuItem5.Text = "&Start Level";
//
// menuItem6
//
Form1.menuItem6.Index = 2;
Form1.menuItem6.Text = "-";
//
// menuItem7
//
Form1.menuItem7.Index = 3;
Form1.menuItem7.Text = "E&xit";
//
// menuItem2
//
Form1.menuItem2.Index = 1;
Form1.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
Form1.menuItem3});
Form1.menuItem2.Text = "&Help";
//
// menuItem3
//
Form1.menuItem3.Index = 0;
Form1.menuItem3.Text = "&About...";
//
// lbl4
//
Form1.lbl4.BackColor = System.Drawing.Color.Black;
Form1.lbl4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
Form1.lbl4.Font = new System.Drawing.Font("Desdemona", 20.25F);
Form1.lbl4.ForeColor = System.Drawing.Color.White;
Form1.lbl4.Location = new System.Drawing.Point(8, 64);
Form1.lbl4.Name = "lbl4";
Form1.lbl4.Size = new System.Drawing.Size(528, 40);
Form1.lbl4.TabIndex = 1;
Form1.lbl4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// pboP1
//
Form1.pboP1.Image = ((System.Drawing.Bitmap)(resources.GetObject("pboP1.Image")));
Form1.pboP1.Location = new System.Drawing.Point(16, 168);
Form1.pboP1.Name = "pboP1";
Form1.pboP1.Size = new System.Drawing.Size(35, 50);
Form1.pboP1.TabIndex = 2;
Form1.pboP1.TabStop = false;
//
// pboP2
//
Form1.pboP2.Image = ((System.Drawing.Bitmap)(resources.GetObject("pboP2.Image")));
Form1.pboP2.Location = new System.Drawing.Point(496, 416);
Form1.pboP2.Name = "pboP2";
Form1.pboP2.Size = new System.Drawing.Size(35, 50);
Form1.pboP2.TabIndex = 3;
Form1.pboP2.TabStop = false;
//
// cmd1
//
Form1.cmd1.Enabled = false;
Form1.cmd1.Font = new System.Drawing.Font("Desdemona", 36F, System.Drawing.FontStyle.Bold);
Form1.cmd1.Location = new System.Drawing.Point(0, 256);
Form1.cmd1.Name = "cmd1";
Form1.cmd1.Size = new System.Drawing.Size(152, 104);
Form1.cmd1.TabIndex = 4;
Form1.cmd1.Text = "Start";
//
// lbl1
//
Form1.lbl1.AutoSize = true;
Form1.lbl1.Font = new System.Drawing.Font("Desdemona", 26.25F);
Form1.lbl1.Location = new System.Drawing.Point(160, 160);
Form1.lbl1.Name = "lbl1";
Form1.lbl1.Size = new System.Drawing.Size(0, 41);
Form1.lbl1.TabIndex = 5;
//
// lbl2
//
Form1.lbl2.AutoSize = true;
Form1.lbl2.Font = new System.Drawing.Font("Desdemona", 26.25F);
Form1.lbl2.Location = new System.Drawing.Point(72, 432);
Form1.lbl2.Name = "lbl2";
Form1.lbl2.Size = new System.Drawing.Size(0, 41);
Form1.lbl2.TabIndex = 6;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.Color.Black;
this.ClientSize = new System.Drawing.Size(544, 529);
this.ControlBox = false;
this.Controls.AddRange(new System.Windows.Forms.Control[] {
Form1.lbl2,
Form1.lbl1,
Form1.cmd1,
Form1.pboP2,
Form1.pboP1,
Form1.lbl4,
Form1.pboBoard});
this.ForeColor = System.Drawing.Color.White;
this.Menu = Form1.mnu1;
this.Name = "Form1";
this.Text = "Elicit Response";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);

}

This created some problems as well; all of the error messages would dissappear, but when I would go under the Form1[Design] tab, all of the controls would dissappear. I would compile the program without any problems; the controls would display, but nothing would work, it would be like there would be no code at all. I have no idea what is wrong, could someone help me out?
GeneralRe: Qualifying Static Members With Type Names Pin
Not Active23-Feb-04 16:53
mentorNot Active23-Feb-04 16:53 
GeneralRe: Qualifying Static Members With Type Names Pin
Heath Stewart24-Feb-04 4:22
protectorHeath Stewart24-Feb-04 4:22 
Questionhow to use dll(mfc) in web service Pin
wangxuefeng23-Feb-04 14:51
wangxuefeng23-Feb-04 14:51 
AnswerRe: how to use dll(mfc) in web service Pin
Heath Stewart24-Feb-04 4:19
protectorHeath Stewart24-Feb-04 4:19 
GeneralRe: how to use dll(mfc) in web service Pin
wangxuefeng24-Feb-04 23:26
wangxuefeng24-Feb-04 23:26 
GeneralRe: how to use dll(mfc) in web service Pin
Heath Stewart25-Feb-04 2:43
protectorHeath Stewart25-Feb-04 2:43 
GeneralRe: how to use dll(mfc) in web service Pin
wangxuefeng25-Feb-04 13:36
wangxuefeng25-Feb-04 13:36 
AnswerRe: how to use dll(mfc) in web service Pin
wangxuefeng24-Feb-04 21:43
wangxuefeng24-Feb-04 21:43 
Generalfile processing Pin
Rob Tomson23-Feb-04 12:47
Rob Tomson23-Feb-04 12:47 
GeneralRe: file processing Pin
je_gonzalez23-Feb-04 15:27
je_gonzalez23-Feb-04 15:27 
GeneralRe: file processing Pin
Heath Stewart24-Feb-04 4:14
protectorHeath Stewart24-Feb-04 4:14 
GeneralRe: file processing Pin
je_gonzalez24-Feb-04 5:04
je_gonzalez24-Feb-04 5:04 
GeneralRe: file processing Pin
Rob Tomson24-Feb-04 17:45
Rob Tomson24-Feb-04 17:45 
GeneralRe: file processing Pin
je_gonzalez24-Feb-04 19:40
je_gonzalez24-Feb-04 19:40 
Questionhow to clear a combobox? Pin
Anonymous23-Feb-04 11:56
Anonymous23-Feb-04 11:56 
AnswerRe: how to clear a combobox? Pin
Werdna23-Feb-04 14:27
Werdna23-Feb-04 14:27 
QuestionHow to get number of running threads? Pin
CWIZO23-Feb-04 11:32
CWIZO23-Feb-04 11:32 

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.