ALL,
I am trying to develop a C# Windows Forms application.
For that I needed to make a custom control that is derived from the GroupBox.
Now for the problem.
I have a form and on the form I put a grid box. On 1 cell I put a GroupBox and on another cell I put my custom control.
For both controls properties I put "ColumnSpan" to be 3 as grid has 3 columns.
The native control display itself properly, meaning it is stretched.
The custom control display itself incorrectly, meaning it is not stretched.
I checked and all properties in the properties inspector are the same.
What am I missing?
Thank you.
For some reason custom controls do not resize themselves. So all I had to do in the GUI designer is to resize the control.
Thank you for reading and hopefully it will help someone else.
Related
I have a WinForms application with a GroupBox in it. I have designed a user control which groups together a bunch of textboxes and other controls so that I can apply some custom logic to them. The user control looks like the following:
I want to place this user control within my GroupBox, however doing so ends up affecting the layout of the controls within my user control (see below).
As you can see, my textboxes are all spread out and resized from how I want them to be. If I place this control directly on the main form or in a Panel (not in the GroupBox) the layout is maintained, however the moment I place it in the GroupBox everything gets messed up. Is there a way to fix this problem?
The user control seems to have a different size in the two cases. Make sure it has the same size in the group box as when you place it directly on the form. If you have used a layouting control like a FlowLayoutPanel or a TableLayoutPanel, this might be of importance.
Also be aware that winforms controls inherit properties from their parent if they are not set explicitly. E.g., if you have not set the font property of the user control and its text boxes, those will be taken from the group box.
What ended up working for me was making a separate class MyGroupBox which extends GroupBox. The class is empty, but I converted the GroupBox on my form to this and placed the user control inside, which solved the problem.
I am working on a WinForm based applications(Yes I don't know WPF) and want's a dashboard like panels in it. Picture given below
Each panel will have a title and records from Database and some action controls. How could this be achieved? I don't want to use GridControl as I don't want to show Excel like spreadsheet here. How could this be achieved?
It sounds like you want to make a UserControl, possibly coupled with an automatic layout panel like FlowLayoutPanel.
Simply speaking, you would create a UserControl with whatever properties and events you require (i.e. in your example you might have a Title property and a Data property), and any events you need to respond to (e.g. you might have a button that you provide a wrapper event for). Then you can add the control to your existing form as you would any other standard control.
As far as displaying data in list form goes, one suggestion is to use a Panel and dynamically add Labels to it. Another idea could be just a simple Label with line breaks in the Text.
I have a ItemControl and i set ItemPanel Property to Horizontal StackPanel and I Bound it to ObservableCollection of Icons.Now I Wanna user be able to remove icons with drag drop them to out of ItemControl and also can change items positions with each other by drag and Drop.
(Look likes MacOSX DocBar).Can i do this with above controls ,if yes,please tell me how.if not,i appreciate to tell me i should use which controls and how
Thanks In Advance.
You should be able to with your own inherited version of the controls. Microsoft writes their controls in a way to allow for easy inheriting and overriding of behavior.
It should be similar to what's done here:
http://www.codeproject.com/Articles/7841/Drag-and-Drop-Treeview-control
You want to watch events like DragStart, and DragLeave, and when it's not over your control and drop is performed do your operation.
More information:
http://msdn.microsoft.com/en-us/library/za0zx9y0.aspx
Good luck.
I'm working with a GUI in PowerShell and trying to make the form such that, after the form is built, the user can interact with the part of the form (+/- button) to dynamically add a group of controls to the form underneath of the existing set.
As an example, there will be a combobox (drop-down) to select a parameter and then a text field to fill in the value for the selected parameter.
What I'm looking for is a way to dynamically add that group of controls to the form when the user clicks the plus button. My current attempts have failed. I've tried pinning the controls inside of a TableLayoutPanel and a Panel object but can't seem to get the items to appear in the first place and then appear in some semblence of order. Is there a GUI object that I can pin the controls to that will just auto-dump the next row of controls below the existing or do I have to figure out the calculations off of the docked parent and offset the Y-values?
Does anyone know a PowerShell accessible Windows form control that would support this type of additions?
One of my attempts is psoted here: .NET 4 (WinForms) Dynamic Form Control Creation in Powershell
Any help is greatly appreciated.
Maybe you could use FlowLayoutPanel. Here is the sample script for using FlowLayoutPanel in Powershell
It's not Winforms, but there is a new module up on Codeplex called ShowUI, which enables you to create WPF based UI's in PowerShell. Take a look at http://showui.codeplex.com. There is some examples up there on using Grid controls and automatic layouts, that I think could meet your needs if you are willing to jump into WPF.
Got the answer from a Microsoft PowerShell forum Moderator:
http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/b2c8abeb-3ae6-4936-9bef-a50a79fdff45/
it's the datagridview object that needs to be used.
Can't you simply build your form (for example with Sapiens free editor tool) with all the controls invisible, and then according to the user choice make them visible ?
I would like to develop a custom Toolstrip control. The control would be like a ToolStrip but with the following features :
The textbox would be proceeded by a label
The textbox would have two buttons after it.
I guess to implement this then a user drawn control would be required. Does anyone know of any resources available on the web to get me started on this.
First you should compose your usercontrol with label, textbox and buttons, exposing all the necessary Properties.
Here's a MSDN WalkThrough for UserControls creation
Then, use this answer (or this MSDN example) to create the custom ToolStripItem, just replace the TrackBar with you custom control.
P.S.
If you don't want to create a ToolStripItem, but just a popup showing your custom control, you can use this other example, replacing the ListBox with your control.