Using Properties Window in runtime to customize windows form controls - c#

Is there a way to use visual studio design-time Properties Window at runtime to customize a specific Control such as DataGridView?
Some thing like image below needed to enable user to customize controls on a Form by changing properties of them.

The PropertyGrid is a standard control. You can add one to your Form or create it at run-time.
In the ToolBox, it's usually found in the All Windows Forms cathegory, or using the search tool.
It can be fully customized and supports transparent colors.
You can use the SelectedObject property to associate it to an existing control and it will populate automatically (this property can also be set at design-time).
The PropertyGrid can then be used to change the associated control's properties at run-time.
propertyGrid1.SelectedObject = this.dataGridView1;

Related

WPF CustomControl in dll

Is it possible to add definition of WPF Custom Control to dll?
There is no such a template in Visual Studio 2015. Only template "WPF User Control" is avaiable, but I don't want to create control from scratch but modernize existing standard control.
The following project types exist that might fit your needs:
WPF Custom Control Library: Custom controls extend one of the WPF control base classes and provide additional functionality through code.
WPF User Control Library: A user control is technically a normal content control which you can extend in some parts in the code but usually it is extended by placing other controls inside of it.
See this answer for more information: What is the difference between a User Control Library and a Custom Control Library?
If I understand you correct, you want to create a User Control based on XAML. In my Visual Studio, this template is called "User Control WPF" and yes, you can add it to a Dll.
To modernize an existing control it might be simple to modifiy the style and ControlTemplate of this control. You can extract style and control template using Blend and then modify it to your needs.

C# settings form under settings menu

Is there a way to display the projects settings in a form inside the application?
I have added a Menu Item called setting, Now when that is clicked I want a small form to popuo with the applications setings.
Is there a quick way to do this that just displays the settings as you would see them in Visual Studio? Or do I have to manually fetch the settings and display them?
If I need to manually do it. Which type of form must I use so that it will appear inside my main form?
I think you'll manually need to collect them and display them. To display on an area inside your main form you'll want to use a UserControl and place your created UserControl on your main form.
Take a look at PropertyGrid control. It's the one what VS uses itself to edit properties of things (aka settings). Displaying things is pretty easy: add PropertyGrid to a form and assign object to it propertyGrid.SelectedObject. You will be able to see and edit properties of that object (in case of configuration settings this will be a configuration class instance I assume) almost right away! Tuning, adding localization, etc are not trivial tasks, but there are plenty of tutorials.
Otherwise, you could possibly use TableLayoutPanel with 2 columns: labels and respective texboxes (or other edit controls, to example, NumbericUpDown for int values), rows are autosized. But then you will have to add label and textbox for each setting yourself, as well as write some code to implement getting/setting of each configuration setting.

How do I add Windows Form Designer support to a custom control?

I am new to the concept of custom controls, and until recently my experience has been limited to extending controls that already exists.
In Visual Studio, how do I add support for my custom controls in the form of Designer Drop Downs and forms?
This picture below identifies the kind of components I am wishing to create for my custom controls.
I'd recommend reading Extending Design Support on MSDN. In this case, you want a custom designer for your type, which can be specified via the DesignerAttribute decorating the type. For details, see Custom Designers.

Create Visual Studio style Options/Settings Dialog

I am currently in the process of improving my options dialog for a winforms application. At the moment I am using a tab control.
I would like to create a form/dialog for settings that is similar to Visual Studio's. How is this done? I can see a treeview like control on the left hand side but what control are they using to display each of the options pages, it doesn't appear to be a tab control. I would like to be able to build the controls for each of the settings at design time.
Thanks.
They look to me like UserControls. I can't say how exactly they implement it, but it would be simple enough to build a UserControl for each option type and swap out the current control when the tree view selection changes. In your designer you would simply have the TreeView and a parent panel to host the UserControls. At runtime you would perform the swap.

Default properties for controls in BIDS 2005 (Report Designer) - Custom Controls

I'm new to BIDS. In Business Intelligence Developer Studio 2005 in the Report designer, the default toolbox has Report Items displayed. My end goal is simply to default the properties of the controls in that toolbox. For example, the Textbox control should be defaulted to a specific font and background color. How can I accomplish this?
I thought this would be a simple matter of inheriting from the windows form textbox control and adding my new 'MyTextBox' control to the toolbar. I was able to add it successfully, but it's disabled and can't be dragged onto the report. I saw the Custom Report Item sample here but since I'm just looking to extend current functionality (or really just set default property values), hoped that it was overkill.

Categories