I want to create a simple tabbed interface app. I did it before in WPF using an usercontrol inside of each tab, and I comunicate with the principal form searching for a parent element (the form, or the tab control)
How could I made the same in WinForms? Which element need I put inside of each tab?
Thanks.
You can use pretty much the same approach in a winforms application. You can add user controls to the tab pages of a TabControl on a form. Inside the user control code you can use the FindForm method to get hold of the parent form.
However, I would suggest that you instead use events to communicate "out" from the controls, in order to make them less dependent on their surroundings.
TabPage and TabControl might be classes and components you would want to look into. Using the Parent property you can access the owning form and thus communicate with it or between tabs, should you need it.
Though, as Fredrik Mörk suggests, using events is a far better practice. =)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With