some more questions :p  
Author Message
RubenPieters





PostPosted: Visual C# Express Edition, some more questions :p Top

yep, its me again and i have some more questions xD

1) how can i create a picturebox in the code itself like when i click button1 then there is a picturebox created

2) i want my 'if' thing to have 2 things in it (like if (MyInt == 0 and MySecondInt == 5)), how do i do this, as 'and' didnt work

3) u can write things in a combobox, but how can i disable that u write things in it

4) u can check and uncheck a radiobutton by clicking it, but how can i do that u cant check and uncheck it by clicking the radiobutton (i have some other ways to check/uncheck the radiobutton)

thx in advance



Visual Studio Express Editions32  
 
 
RubenPieters





PostPosted: Visual C# Express Edition, some more questions :p Top

nvm question 2 ^^ found it myself now
 
 
RubenPieters





PostPosted: Visual C# Express Edition, some more questions :p Top

oh i got another question (lol i forgot it when i typed the thread xD)

5) I want my game to have a startup form, so i have got the startup form(that starts first) and then when i click a button the form closes and then there comes my game form, how can i do this :)


 
 
nobugz





PostPosted: Visual C# Express Edition, some more questions :p Top

Q1:
private void button1_Click(object sender, EventArgs e)
{
PictureBox box = new PictureBox();
box.Name = "PictureBox1";
box.Location = new Point(5, 5);
box.Size = new Size(100, 100);
box.BackColor = Color.ForestGreen;
this.Controls.Add(box);
}
Change other properties as necessary. You can always duplicate the code that the Forms designer generates. To see it, click Show All Files in the Solution Explorer, open the node next to the form and double-click the Designer.cs file.

Q2: if (MyInt == 0 && MySecondInt == 5)

Q3: comboBox1.Enabled = false;

Q4: radioButton1.Enabled = false;

Q5: modify Program.cs as follows:
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
frmSplash frm = new frmSplash();
if (frm.ShowDialog() == DialogResult.OK)
Application.Run(new Form1());
}

frmSplash:
private void button1_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
}



 
 
RubenPieters





PostPosted: Visual C# Express Edition, some more questions :p Top

sry m8 but your picturebox code isnt working :( it does nothing when i click the button, but it doesnt give errors either

and that thing in the program.cs isnt that right either, in the 'frmSplash:' line i get error that there cant be a ':' and when i remove it i get some other error


 
 
nobugz





PostPosted: Visual C# Express Edition, some more questions :p Top

You can't see the picturebox unless you set the backcolor (which I did) or set the image property.

I used "frmSplash:" to tell you to put that code in the frmSplash source code, don't put it in Program.cs


 
 
RubenPieters





PostPosted: Visual C# Express Edition, some more questions :p Top

You can't see the picturebox unless you set the backcolor (which I did) or set the image property.

i know what the problem is, i wanted to put it above another picturebox, but it is prolly putted under the picturebox, any command that can put it above the other picturebox


 
 
RubenPieters





PostPosted: Visual C# Express Edition, some more questions :p Top

and where do i find the frmsplash source code :<
 
 
nobugz





PostPosted: Visual C# Express Edition, some more questions :p Top

Yes, it puts it behind another control. Fix it like this:
...
this.Controls.Add(box);
box.BringToFront();

There is no source code for frmSplash, just a pretty picture and a button. I gave you the code for the button, the rest (if any) is up to you.



 
 
RubenPieters





PostPosted: Visual C# Express Edition, some more questions :p Top

another question for the picturebox would it be possible to make the name, the number of a label, but once the picturebox is created with the number 1 for example, it stays nr 1(so when the label text changes, the picturebox name doesnt change) or if that is not poss, the text of a label is ok also.
 
 
RubenPieters





PostPosted: Visual C# Express Edition, some more questions :p Top

oh and i still dont understand where exactly i need to put this: (for in the frmsplash thing)

private void button1_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
}