Soo... I am making a control like the Windows Update "panels".
Everything's fine up to the "container" part.
What I want to do is to allow the designer to place controls in a Panel which is inside my control.
(The panel's variable is held in my control's class and inside the control itself.)
How do I bypass this?
As a reference, you might want to try out this AeroWizard Control, which does this pretty well.
(Yes, I have looked at it and didn't find a clue but custom designers!)
As a side note, I'd rather not make a complicated designer class...
If you don't want to create a custom designer class, you should implement your control as a templated custom control, preferably inheriting from CompositeControl.
There doesn't seem to be a way to do the same in Windows Forms without a custom designer class. However, there's a nice, short, working example of such a designer here.
Related
I've created a groupbox that is used to populate a list of files and their description. I've also written the code behind for properly adding the files. Is it possible to share the code behind and UI so that it can be used in other forms without having to rewrite the code? I know that you can create a base form, that contains the winforms control you want to share. That way you can have your new form you inherit from the base class. But I'm not looking to implement it this way.
YES, it can be. Create a User Control for your GroupBox and use the same in whichever form you want. User controls are meant for that purpose to increase code re-usability.
In case, you think the same GroupBox control can be used in other project as well then you should consider building it as Custom Control
I am currently working with a 3rd party ActiveX Control (an editor for topographical data distributed by Cadcorp SIS). I have to do some fairly complex stuff with it in a VB.NET (framework 4) program and am finding that the API that comes with the control is quite limited.
As of now I have made a custom control which houses the control and acts as a wrapper for it to allow me to extend the API, which works fine, but What I would really like to do it give the control more events so that I can monitor what is going on with the data more closely.
I'm not sure how to go about doing this though...
I tried inheriting from the control and I can extend it just fine, but I can't figure out how to reuse it after that. Is there some way I can inherit the control and get it to appear in the toolbox so I can just drop it onto a form? Or do I have to load it programatically? If so, how can I do it?
Any pointers, examples, tutorials or alternative ideas as to how to do this kind of thing would be welcome.
If you are not seeing your control class in toolbox it doesn’t mean that you can’t use it just modify code from your form's designer to use your inherited class
Or
You can drag-and-drop your assembly (dll) from Windows Explorer to the
toolbox in VS.NET. Or you can right click on the toolbox in VS.NET and
choose Add/Remove items. Is this what you are looking for?
Also
<ToolBoxItem(True), ToolboxBitmap("MyNamespace.MyClass.bmp")> _
Public Class MyClass
In this scenario I have a base component with a close button and a flow panel; (FlowLayoutPanel) the idea being that components extending this add their controls to the flow panel and will have the close button functionality done for them.
The problem is that I can't seem to persuade VS to add the components in the subclassed component to the flow panel; this ends up with me having to do so in the code. Which is all well and good except that it won't show up in the designer view. If I add it to the partial class with the designer generated code then I can see the controls in the designer view laid out by the flow panel. But this just gets overwritten afterwards.
Visual Studio doesn't seem to let you dock controls in inherited panels - unless I'm doing something wrong? I did make sure that the base panel is publically visible in case this was the issue.
--
An alternative might be some way to persuade the designer to execute/not overwrite my code in the designer class.
You need to make a ControlDesigner for your control and override the InternalControlDesigner and GetParentForComponent methods.
For an example, open System.Windows.Forms.Design.SplitContainerDesigner (in System.Design.dll in Reflector.
I have an application that will run in two modes, each with very similar displays. The application is supposed to allow easy modification of a user interface. One of the features is that it has to display the user interface. Both of these windows look the same, just one has more menus than the other.
I'd like to just create a base template (the user visual) and then inherit it for the editor. That way if one interface changes, both of them change. But this doesn't seem to be possible using WPF. I try to inherit and I get warnings about hiding members. I also don't see how I'm going to append new menus to the base template.
Is what I'm trying to do possible? Is there a better way that I'm supposed to be doing this? It seems like I'm fighting the way that they want me to make the application.
If I got your question properly, all you have to do is create a style for a window in shared resources. When user changes a style it will be automatically applied to every control that uses this style.
For the custom parts you could use ContentPresenters and custom controls..
My question is related to this question:
Baseline snaplines in custom Winforms controls
However, in my case, I have created a new control that derives from TextBox rather than containing a TextBox. I would like to have a custom ControlDesigner, but I would like to modify the behavior of the TextBox's designer rather than having to write a complete designer myself. In particular, I'd like to be able to return the TextBox's SnapLines while providing some custom verbs. Is there a good way to do this?
EDIT: To clarify, this is for Windows Forms in .NET 2.0.
In the end, the solution I settled on was to create a dummy control in the designer, sync the relevant properties with the real control, get the designer for the dummy control, and then return the snaplines from the dummy control's designer. It's a terrible hack, but it seems to be the only way without using reflection to "extend" a designer.
What about having your ControlDesigner derive from the one that TextBox is using? Did you try that and find a problem?