Link to home
Start Free TrialLog in
Avatar of Ron Kidd
Ron KiddFlag for Australia

asked on

Set Windows Forms Controls as Public

Is there anything wrong with setting windows forms controls to Public?

I am wanting to make a Project of "Search Forms" that I can simply import into different Projects that access the same Database design.
But I can't access the form controls from the other Projects unless the Controls are set to Public
Avatar of Karrtik Iyer
Karrtik Iyer
Flag of India image

Hi @p-plater,

I suggest to make the search part which you want to reuse across multiple projects as user control and use it across all forms including Search-Forms.
https://msdn.microsoft.com/en-us/library/aa302342.aspx
By making control public, the form loses the control (does not know) when some property/state of a control is modified.  Also form may contain lot more things then just the control that you want to be reuse, in that case it is a overhead for every other project to import all the controls via form although they might be interested in only using one of the controls.

Thanks,
Karrtik
SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Kaufmed is right if you understand what he says and are at a level to implement these features.

I gave you the easy way to do what you wanted, judging your expertise by the questions that you asked in the past. I might be wrong in my judgement.

If you are up to it, he gave you the proper way to do it.
Avatar of Ron Kidd

ASKER

If I understand what Kaufmed is saying correctly then what I need to do is put the Search Forms in the BLL DLL?
So when the UI sends a Search to the BLL if it needs to display a search form then the BLL displays the form then it can return the selected values back to the UI.

Is this Correct?

The only drawback in doing it that way is it makes the BLL Windows Forms dependant. (If I need to make a WPF application it would need a Modified BLL)

Am I Understanding it correctly?
Yes.

But if you think to eventually go to WPF, although I am no expert on that subject, it seems that there are ways to use windows form with WPF applications.

You might thus use conditional compilation to automatically create 2 different versions of the same dll from the same source code. One that displays the Windows Form normally, and the other one that uses the tools in the System.Windows.Forms.Integration Namespace.
Many Thanks Yet Again.

Experts Exchange is a wealth of Knowledge.