better way to draw common ui interfaces on more than 1 form
-
I need a bit of approach advice. I have 2 forms that have the same custom section of form drawn in each. The controls are drawn according to some data in the database. At the moment I thought about copying the Code from one form to the other but I am sure there is a better way! Any pointer for me to read upon ?
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
-
I need a bit of approach advice. I have 2 forms that have the same custom section of form drawn in each. The controls are drawn according to some data in the database. At the moment I thought about copying the Code from one form to the other but I am sure there is a better way! Any pointer for me to read upon ?
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
If the same piece of UI appears on more than 1 form, it would seem prudent to create that part of the UI as a UserControl and host it on both forms. The logic should be encapsulated neatly then.
Forgive your enemies - it messes with their heads
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
If the same piece of UI appears on more than 1 form, it would seem prudent to create that part of the UI as a UserControl and host it on both forms. The logic should be encapsulated neatly then.
Forgive your enemies - it messes with their heads
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
potentially a blonde question here but is it considered better to pass the database data too it rather than getting the user control to query the database?
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
-
potentially a blonde question here but is it considered better to pass the database data too it rather than getting the user control to query the database?
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
I would have a central repository for the database data. a cache if you like, and just query that from the user control - it's one location for the UC to talk to, and it's easy to implement using a static class.
Forgive your enemies - it messes with their heads
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
I need a bit of approach advice. I have 2 forms that have the same custom section of form drawn in each. The controls are drawn according to some data in the database. At the moment I thought about copying the Code from one form to the other but I am sure there is a better way! Any pointer for me to read upon ?
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
-
As an alternative; create a form that contains the common controls, and inherit both other forms from there. Making it a UserControl, as already suggested, would be a better idea though :)
Bastard Programmer from Hell :suss:
Personally, i would go for the inheritance method even thought user control is a great approach.
-
Personally, i would go for the inheritance method even thought user control is a great approach.
John T.Emmatty wrote:
Personally, i would go for the inheritance method even thought user control is a great approach.
It's an option; but you can use multiple UserControls in different forms - and inherit only from one form at a time.
Bastard Programmer from Hell :suss:
-
I need a bit of approach advice. I have 2 forms that have the same custom section of form drawn in each. The controls are drawn according to some data in the database. At the moment I thought about copying the Code from one form to the other but I am sure there is a better way! Any pointer for me to read upon ?
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
Why not have a custom control that wil talk to database and render itself accordingly. this can be used on both the forms.