2 Problems with Visual C#

  • Thread starter Thread starter Michaelas10
  • Start date Start date
M

Michaelas10

The first one is: Cannot implicitly convert type 'int' to 'bool'
The second one: 'System.Windows.Forms.FormWindowState' is a 'type'

The code is:



private void button6_Click(object sender, EventArgs
e)
{
int i;
if (i = 2)
{
i = 0;
}
else
{
i += 1;
}
if (i = 1)
{
FormBorderStyle = FormBorderStyle.None;
FormWindowState = FormWindowState.Maximized;
button6.Text = "Normal Screen";
}
else
{
FormBorderStyle = FormBorderStyle.Sizable;
FormWindowState = FormWindowState.Maximized;
button6.Text = "Full Screen";
}
}


Oh, how can i use the "static" thing in C#?
Sorry, i worked long time with Visual Basic and it's hard for me to
move to another language.

Michaelas10
 
It's "if (i == 2)" (with two =) instead of "if (i = 2)".

S. L.

Michaelas10 said:
The first one is: Cannot implicitly convert type 'int' to 'bool'
The second one: 'System.Windows.Forms.FormWindowState' is a 'type'

The code is:



private void button6_Click(object sender, EventArgs
e)
{
int i;
if (i = 2)
{
i = 0;
}
else
{
i += 1;
}
if (i = 1)
{
FormBorderStyle = FormBorderStyle.None;
FormWindowState = FormWindowState.Maximized;
button6.Text = "Normal Screen";
}
else
{
FormBorderStyle = FormBorderStyle.Sizable;
FormWindowState = FormWindowState.Maximized;
button6.Text = "Full Screen";
}
}


Oh, how can i use the "static" thing in C#?
Sorry, i worked long time with Visual Basic and it's hard for me to
move to another language.

Michaelas10
 
And for your second problem, you have to replace

FormWindowState = FormWindowState.Maximized

by

this.WindowState = FormWindowState.Maximized (or WindowState =
FormWindowState.Maximized)
 
the code: panel3.Dock = DockStyle.Right(); - gives me the
error:

'System.Windows.Forms.DockStyle.Right' is a 'field' but is used like a
'method'.
 
the code: panel3.Dock = DockStyle.Right(); - gives me the
error:

'System.Windows.Forms.DockStyle.Right' is a 'field' but is used like a
'method'.


Remove the parentheses.



Mattias
 
The brackets after DockStyle.Right

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
Mattias Sjögrenwrote:
[quote:e324bdccd8]the code: panel3.Dock = DockStyle.Right(); -
gives me the
error:

'System.Windows.Forms.DockStyle.Right' is a 'field' but is used like a
'method'.

Remove the parentheses.



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.[/quote:e324bdccd8]

Sorry but what is parentheses?

Michaelas10
 
Back
Top