Click here to Skip to main content
14,387,840 members
   

C#

 
AnswerRe: Type Overflow... Pin
Richard Deeming15-Nov-19 2:20
mveRichard Deeming15-Nov-19 2:20 
GeneralRe: Type Overflow... Pin
Bernhard Hiller15-Nov-19 5:55
MemberBernhard Hiller15-Nov-19 5:55 
QuestionAdding panels dynamically through user input Pin
jacko112313-Nov-19 2:34
Memberjacko112313-Nov-19 2:34 
AnswerRe: Adding panels dynamically through user input Pin
OriginalGriff13-Nov-19 2:45
mveOriginalGriff13-Nov-19 2:45 
GeneralRe: Adding panels dynamically through user input Pin
jacko112313-Nov-19 3:20
Memberjacko112313-Nov-19 3:20 
SuggestionRe: Adding panels dynamically through user input Pin
Richard Deeming13-Nov-19 2:58
mveRichard Deeming13-Nov-19 2:58 
GeneralRe: Adding panels dynamically through user input Pin
jacko112313-Nov-19 3:19
Memberjacko112313-Nov-19 3:19 
AnswerRe: Adding panels dynamically through user input Pin
Luc Pattyn13-Nov-19 4:12
sitebuilderLuc Pattyn13-Nov-19 4:12 
I have more comments to add:

1. assuming nameLabel and testButtons are controls, you are adding them to every Panel you create. However a Control can have only one Parent, so the last addition will win, your nameLabel and testButtons will only belong to and appear on the last Panel you created! If you want them to show on whatever Panel you make visible, you either have to create them for each Panel, or move them around from one Panel to the next that becomes visible. The easy alternative is to put them on your Form itself, not on a switching Panel.

2. your newPanel.Show(); will apply to every Panel you create; it also undoes your newPanel.Visible = false; You should decide how you make one and only one Panel visible: either have them all but one invisible (then don't use Show), or make them all visible and modify their z-order, see e.g. c# - How to set Z-order of a Control using WinForms - Stack Overflow[^] . (I would go for the former). Same applies to your click handler code.

1+2. you need a method that makes a panel visible, by
a) making the previous one (if any) invisible (Visible=false)
b) making the selected one visible, i.e. visible=true, and testButtons.Parent=this;
Your click handler would then call this method, as probably would your Load handler.

3. I would be inclined to create all panels at once (unless there are hundreds of them of course).

4. I see no need to specify a name for all these panels. If you later need to refer to a specific Panel, have a look at the Tag property, where you can store any number, string, Control reference, or whatever fits your needs.

Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum

QuestionHow to Import database.mdf file in Visual Studio 2010 Project Pin
Member 1464246912-Nov-19 0:59
MemberMember 1464246912-Nov-19 0:59 
AnswerRe: How to Import database.mdf file in Visual Studio 2010 Project Pin
OriginalGriff12-Nov-19 1:07
mveOriginalGriff12-Nov-19 1:07 
GeneralRe: How to Import database.mdf file in Visual Studio 2010 Project Pin
Member 1464246912-Nov-19 1:29
MemberMember 1464246912-Nov-19 1:29 
GeneralRe: How to Import database.mdf file in Visual Studio 2010 Project Pin
OriginalGriff12-Nov-19 1:46
mveOriginalGriff12-Nov-19 1:46 
GeneralRe: How to Import database.mdf file in Visual Studio 2010 Project Pin
Member 1464246912-Nov-19 19:28
MemberMember 1464246912-Nov-19 19:28 
GeneralRe: How to Import database.mdf file in Visual Studio 2010 Project Pin
OriginalGriff12-Nov-19 21:44
mveOriginalGriff12-Nov-19 21:44 
Questionc++ DLL import in c# Pin
Member 1465244911-Nov-19 20:49
MemberMember 1465244911-Nov-19 20:49 
AnswerRe: c++ DLL import in c# Pin
Richard MacCutchan11-Nov-19 22:12
mveRichard MacCutchan11-Nov-19 22:12 
GeneralRe: c++ DLL import in c# Pin
Member 1465244912-Nov-19 20:44
MemberMember 1465244912-Nov-19 20:44 
GeneralRe: c++ DLL import in c# Pin
Richard MacCutchan12-Nov-19 23:09
mveRichard MacCutchan12-Nov-19 23:09 
QuestionCode not splitting for login form. C# Pin
Member 1465157011-Nov-19 2:10
MemberMember 1465157011-Nov-19 2:10 
AnswerRe: Code not splitting for login form. C# Pin
phil.o11-Nov-19 2:19
mvephil.o11-Nov-19 2:19 
AnswerRe: Code not splitting for login form. C# Pin
Richard MacCutchan11-Nov-19 2:32
mveRichard MacCutchan11-Nov-19 2:32 
GeneralRe: Code not splitting for login form. C# Pin
OriginalGriff11-Nov-19 2:32
mveOriginalGriff11-Nov-19 2:32 
GeneralRe: Code not splitting for login form. C# Pin
Richard MacCutchan11-Nov-19 2:50
mveRichard MacCutchan11-Nov-19 2:50 
AnswerRe: Code not splitting for login form. C# Pin
OriginalGriff11-Nov-19 2:32
mveOriginalGriff11-Nov-19 2:32 
NewsRe: Code not splitting for login form. C# Pin
Eddy Vluggen11-Nov-19 4:20
mveEddy Vluggen11-Nov-19 4:20 

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.