Click here to Skip to main content
16,017,881 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I have a Winform with 2 tabs that contains several actions (account login, DataGridView ect..), and I would like to customize these 2 tabs.

Is it possible to transfer the content of the 2 tabs to 2 UserControls?

Thanks


What I have tried:

I tried to do this but I didn't succeed, but I'm not surprised because I'm debtant in C#
Posted
Updated 24-May-23 10:00am
Comments
Graeme_Grant 24-May-23 9:03am    
I think so. Select all controls, CTRL-C, select the UserControl surface and paste (CTRL-V).
BillWoodruff 24-May-23 13:41pm    
Yes, it is possible, but, if you are new to C# (debutant) why are you taking on this advanced problem ?

Learn to use UserControls and Events ... and show the code you tried.

1 solution

Yes, it should - I use UserControls on Tab a fair amount because it's way easier to edit them. Just create the empty UserControls first, then copy'n'paste will work for the controls themselves in the design view, but you will have to also copy'n'paste the event handler code, then manually hook it all back up again (or copy'n'paste in the designer.cs file - but I'd suggest making a good backup of the project before you start if you are going that route - the VS designer can get a little antsy if you make a mistake in the designer file and it can take ages to fix and get your controls visible again!)
 
Share this answer
 
Comments
BillWoodruff 24-May-23 13:37pm    
Yes !
OriginalGriff 24-May-23 15:19pm    
Thanks Bill!
Off topic, I found a recipe online for Pad Prik King (I love Red Thai Curry, but Herself is on a diet so Coconut milk is out the window) so I tried it this evening and my word it was bloody delicious. No idea if it tasted in any way original, but I'll be doing it again ... I don't remember seeing it anywhere when I was out in Thailand, but that was decades ago so I'm not surprised. Plus not being able to read Thai didn't help :D
BillWoodruff 24-May-23 16:27pm    
Hi Griff,

Pad Prik King/Khing: Will reply to you by PM re this mouth-watering dish :)

cheers, Bill
QuickSilvain 2023 24-May-23 16:01pm    
@OriginalGriff, Thank you very much.. i don't see what you mean by "event handler, then manually reconnect it"

Can you tell me how to do it?
OriginalGriff 24-May-23 16:15pm    
Just connect it to it's handler method in the same way you do any other control event in the designer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900