Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 136,806 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 2,277 people online right now. Registration is fast and FREE... Join Now!




I'm kinda new to C Sharp.

 
Reply to this topicStart new topic

I'm kinda new to C Sharp., How do I make a new panel when you click on a next button?

EvolutionMedia
2 Oct, 2008 - 11:51 AM
Post #1

D.I.C Head
**

Joined: 11 Aug, 2008
Posts: 83



Thanked: 1 times
My Contributions
Hey

I decided to develope a small program in Visual C#. I made a new CodeFile and I thought it would be a Header file because I know in C that's what it was called or a Include File. But I'm kinda confused with C#. In my other project that I was able to successfully make a new Tab page - however, it seems not the same in C#. So I was in the Function that makes the new panel.

Oh, btw - this program is like a quick easy wizard. So like it goes through steps like 1 - 5 steps. Each steps it changes the other panel that I have. Should I like make a panel in the designer mode then hide it from view then when the user clicks on next button it will hide that panel than show up the next one and so on. In VB.NET it's:

CODE

Dim NewTab as New TabPage;


That's creating a new tab in VB.NET but I'm not sure how to create a new panel in C#.

Help would be appreciated! Thanks!

-3v0lut10n (Paul)

User is offlineProfile CardPM
+Quote Post

eclipsed4utoo
RE: I'm Kinda New To C Sharp.
2 Oct, 2008 - 11:55 AM
Post #2

D.I.C Regular
Group Icon

Joined: 21 Mar, 2008
Posts: 375



Thanked: 19 times
Dream Kudos: 25
My Contributions
csharp

TabPage NewTab = new TagPage();


This post has been edited by eclipsed4utoo: 2 Oct, 2008 - 11:55 AM
User is online!Profile CardPM
+Quote Post

EvolutionMedia
RE: I'm Kinda New To C Sharp.
2 Oct, 2008 - 12:02 PM
Post #3

D.I.C Head
**

Joined: 11 Aug, 2008
Posts: 83



Thanked: 1 times
My Contributions
okay, it's a new Panel not a new tab. Plus when I type in PanelPage = NewPanel = new ...

The intellisense doesn't show up for a new Panel. Plus I'm working in a Code File which is seperate from the Main Form. So I don't think it's gonna work like you wrote.
User is offlineProfile CardPM
+Quote Post

EvolutionMedia
RE: I'm Kinda New To C Sharp.
2 Oct, 2008 - 12:21 PM
Post #4

D.I.C Head
**

Joined: 11 Aug, 2008
Posts: 83



Thanked: 1 times
My Contributions
Here's the Codefile

CODE

public class main_module
{
    int step = 0;

    

    public void CreateNewPhase()
    {
        step += 1;

        NewPanel = new System.Windows.Forms.Panel();
        NewPanel.name = "Panel" & step;




    }

    public void GoNextStep(int count)
    {
    
    }

}


Here's when you click on the next button.

CODE

main_module.CreateNewPhase();



Thanks for the help! smile.gif

-Paul
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: I'm Kinda New To C Sharp.
2 Oct, 2008 - 12:30 PM
Post #5

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,997



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
You have to tell it where to add the new Panel to, like your form. Look at the code:

csharp

public void CreateNewPhase(System.Windows.Forms.Form frm)
{
step += 1;

System.Windows.Forms.Panel NewPanel = new System.Windows.Forms.Panel();
NewPanel.name = "Panel" & step;
frm.Controls.Add(NewPanel);



}


Then when you call it (if you're calling it from the form you want to add the Panel to)

csharp

main_module.CreateNewPhase(this);

User is offlineProfile CardPM
+Quote Post

eclipsed4utoo
RE: I'm Kinda New To C Sharp.
2 Oct, 2008 - 01:10 PM
Post #6

D.I.C Regular
Group Icon

Joined: 21 Mar, 2008
Posts: 375



Thanked: 19 times
Dream Kudos: 25
My Contributions
csharp

public void CreateNewPhase()
{
step += 1;

System.Windows.Forms.Panel NewPanel = new System.Windows.Forms.Panel();
NewPanel.name = "Panel" & step;
}

User is online!Profile CardPM
+Quote Post

EvolutionMedia
RE: I'm Kinda New To C Sharp.
2 Oct, 2008 - 01:35 PM
Post #7

D.I.C Head
**

Joined: 11 Aug, 2008
Posts: 83



Thanked: 1 times
My Contributions
Alright, so far so good the only thing is that it's having trouble with the step part.

It's saying that

QUOTE

Error 1 An object reference is required for the non-static field, method, or property 'main_module.step' C:\Users\Evolution\Documents\Visual Studio 2008\Projects\Prankzter1\Prankzter1\CodeFile1.cs 11 9 Prankzter1



I have it like this:

csharp


public class main_module
{
int step = 0;




public static void CreateNewPhase(System.Windows.Forms.Form frm)
{

step = +1;



System.Windows.Forms.Panel NewPanel = new System.Windows.Forms.Panel();



NewPanel.Name = "Panel" & step;


frm.Controls.Add(NewPanel);



}

public void GoNextStep(int count)
{

}

}


I looked up MSDN help and but it's a shitty help reference. I tried saying public int step;

then inside the funciton i put it as step = 0;

but that didn't do good and plus i don't think that would work because everytime it would runt he code it was just reset back to 0 and wouldn't do it's job like i wanted it to.

Thanks guys - I'm more familiar with VB.NET and just trying to get C# under my belt.

Peace and thanks fro the help!

-Paul
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: I'm Kinda New To C Sharp.
2 Oct, 2008 - 02:06 PM
Post #8

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,997



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
You're trying to reference a non-static variable inside a static method. Change this

csharp

int step = 0;


to

csharp

private static int step = 0;

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 02:24PM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month