I am developing a windows application with lot of forms. And each form has got lot of grids etc.
Each developer has to put the grid on a form and then put a label on the top left corner of the grid
and an button named actions (on the right corner of the grid) which would open a pop up menu etc when they select an item in the grid and click actions etc.
So each developer has to align all the above controls on the form thus wasting lot of development time.
Is it possible that I can combine all the above 3 items into a custom control or a ui control or some code (I am not sure..) so that the developers can drag the item from tool box and then be able to modify the location and size at design time.I still want all the properties/methods/events etc of lablel,command button and grid to be visible to developers at design time and at run time.
Do you have any suggestions.
I tried to create a generic code and then call the generic code after the InitializeComponent of the form. But there are 2 draw backs
1) The developer has to copy the code in each and every form and change some initial values.
2) The developer should be able to see the controls in design time on the form. Though it works fine in run time , it doesnot show up in design time where exactly those controls apperas in the form.
Easy enough. Add a Control Library project to your solution. You will get a default UserControl1 designer. Put your label, button and grid on this. (IMPORTANT) Set the control's modifier property to Public that way you can easily get to the contained controls without having to expose all the properties manually.
Compile the control library.
Go to your toolbox, right-click, Add/Remove Items...
Click browse on the .Net tab. Find the dll of the library you just compiled. Select it, then hit OK.
You will notice on the bottom of your toolbox your user control. Drag it on to the form and you will see it with full design time support.
Tips:
First, you probably want to use anchors in your user control so when the control is resized, all the child controls on your control will be resized as well.
You will want to create custom properties if you want the properties to show up in the designer window. So, if you want to be able in design time to set the text of the button, you might want to expose a property on your control that would allow you to do that and add the correct attributes to the property so it shows up in the designer (you will have to search the attributes out, I don't know them).
I will attach a simple project for you in my next post...
Thank you so much hellswraith. If soone has idea about how to access the design time propeties of lable,data grid and command at design time for the above control I would appreciate it.
Also I should be able to select/see all the properties/methods/events for the above control(label,command,datagrid) at design time once I place it on a form.