I have a combobox in my winform, and I wish change the button that show the list (with the triangle) with another button or at least change the image..
it's possible? how can I do this?
thanks!
you should use OwnerDrawn techniques like the one described here: https://stackoverflow.com/questions/2891981/net-ownerdraw-combobox-vista-7-themed-dropdownlist
or you override the window proc and redefine whole control message handling or you create your own control from scratch or you use third party controls like DevExpress WinForms suite or Telerik ones.
Related
I want to show my custom control(eg: monthcalendar) as a drop-down (popup) window.
One option is to use ToolStripDropDown and ToolStripControlHost as the second example in msdn example.
My doubt is:
ToolStripDropDown should be used for ToolStrip items - is this correct or not?
Any other better options to achieve the above requirement?
If you have a simple control, it should be completely fine to use the ToolStripDropDown/ToolStripControlHost combination. More complex controls, however, have sizing, focus, and tab order issues that are difficult to correct. I would recommend that if your custom control has more than one "edit" type child control in it, you're probably better off creating a custom dialog and not trying to make it work in a dropdown.
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 am writing a windows forms application that has a lot of textboxes. I want to add a label or a caption to the textbox, so that I don’t have to drag a lot labels onto the form and deal with positioning etc. So far I have found 2 possible ways to do this.
Create a user control with the label and textbox. How do I get the
control, label and textbox to size appropriately depending on the
text entered since the control will be reusable and different text sizes will be entered. How to get all the
properties and events of the textbox to remain the same.
Extend a normal textbox and add a string property called label or
caption, and show this property at the left of the textbox. I know
this can be done in Web.UI with CSS but is it possible in a winform
and how?
Any suggestions on how to do either of these?
Thanks.
You can create a UserControl that contains a label and a textbox. When you add the user control to your form, both the label and the textbox within will be added simultaneously. You can expose properties of the label and textbox to assign values at design or run time.
Using this method, you can add multiples of the user control to standardize the layout. As far as resizing the controls based on the text, you'll have to subscribe to events and change the sizing manually.
For example, you can subscribe to the TextChanged event of the label and the textbox. When the event fires, you calculate the size of the string and then adjust the width and position of the controls accordingly.
If you get to the point where you have too many textboxes, I would suggest switching to a DataGridView. The GridView component is very well suited for what you're describing, but of course it requires you to accept a grid layout.
One of the bonuses involved in using a GridView is hard to appreciate until you see it in action: it creates only one HWINDOW at a time (two if you're in editing mode). If you create Labels and TextBoxes all over your form, each one is registered with the operating system as an HWINDOW object. All those HWINDOW objects take time to display! In .NET 1.0, WinForms was so slow that dialogs with more than about two dozen controls were unusable. Even though .NET 2.0 is much better in this regard, but you'll still get significantly better performance by using a single control that manages lots of data, as opposed to lots of controls that each manage one piece of data.
Oh, and another option, if you like: you can also try a PropertyGrid. It has the advantage that it will also show help and allow you to create complex editing controls for each element.
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.