Click here to Skip to main content
15,867,756 members
Home / Discussions / C#
   

C#

 
AnswerRe: Type Overflow... Pin
Richard Deeming15-Nov-19 1:20
mveRichard Deeming15-Nov-19 1:20 
GeneralRe: Type Overflow... Pin
Bernhard Hiller15-Nov-19 4:55
Bernhard Hiller15-Nov-19 4:55 
QuestionAdding panels dynamically through user input Pin
jacko112313-Nov-19 1:34
jacko112313-Nov-19 1:34 
AnswerRe: Adding panels dynamically through user input Pin
OriginalGriff13-Nov-19 1:45
mveOriginalGriff13-Nov-19 1:45 
GeneralRe: Adding panels dynamically through user input Pin
jacko112313-Nov-19 2:20
jacko112313-Nov-19 2:20 
SuggestionRe: Adding panels dynamically through user input Pin
Richard Deeming13-Nov-19 1:58
mveRichard Deeming13-Nov-19 1:58 
GeneralRe: Adding panels dynamically through user input Pin
jacko112313-Nov-19 2:19
jacko112313-Nov-19 2:19 
AnswerRe: Adding panels dynamically through user input Pin
Luc Pattyn13-Nov-19 3:12
sitebuilderLuc Pattyn13-Nov-19 3: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 1464246911-Nov-19 23:59
Member 1464246911-Nov-19 23:59 
AnswerRe: How to Import database.mdf file in Visual Studio 2010 Project Pin
OriginalGriff12-Nov-19 0:07
mveOriginalGriff12-Nov-19 0:07 
GeneralRe: How to Import database.mdf file in Visual Studio 2010 Project Pin
Member 1464246912-Nov-19 0:29
Member 1464246912-Nov-19 0:29 
GeneralRe: How to Import database.mdf file in Visual Studio 2010 Project Pin
OriginalGriff12-Nov-19 0:46
mveOriginalGriff12-Nov-19 0:46 
GeneralRe: How to Import database.mdf file in Visual Studio 2010 Project Pin
Member 1464246912-Nov-19 18:28
Member 1464246912-Nov-19 18:28 
GeneralRe: How to Import database.mdf file in Visual Studio 2010 Project Pin
OriginalGriff12-Nov-19 20:44
mveOriginalGriff12-Nov-19 20:44 
Questionc++ DLL import in c# Pin
Member 1465244911-Nov-19 19:49
Member 1465244911-Nov-19 19:49 
AnswerRe: c++ DLL import in c# Pin
Richard MacCutchan11-Nov-19 21:12
mveRichard MacCutchan11-Nov-19 21:12 
GeneralRe: c++ DLL import in c# Pin
Member 1465244912-Nov-19 19:44
Member 1465244912-Nov-19 19:44 
GeneralRe: c++ DLL import in c# Pin
Richard MacCutchan12-Nov-19 22:09
mveRichard MacCutchan12-Nov-19 22:09 
QuestionCode not splitting for login form. C# Pin
Member 1465157011-Nov-19 1:10
Member 1465157011-Nov-19 1:10 
AnswerRe: Code not splitting for login form. C# Pin
phil.o11-Nov-19 1:19
professionalphil.o11-Nov-19 1:19 
AnswerRe: Code not splitting for login form. C# Pin
Richard MacCutchan11-Nov-19 1:32
mveRichard MacCutchan11-Nov-19 1:32 
GeneralRe: Code not splitting for login form. C# Pin
OriginalGriff11-Nov-19 1:32
mveOriginalGriff11-Nov-19 1:32 
GeneralRe: Code not splitting for login form. C# Pin
Richard MacCutchan11-Nov-19 1:50
mveRichard MacCutchan11-Nov-19 1:50 
AnswerRe: Code not splitting for login form. C# Pin
OriginalGriff11-Nov-19 1:32
mveOriginalGriff11-Nov-19 1:32 
NewsRe: Code not splitting for login form. C# Pin
Eddy Vluggen11-Nov-19 3:20
professionalEddy Vluggen11-Nov-19 3: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.