Good day S-O
Need help in developing a Custom combobox.
I should be able to display items like
10
20
30
Custom...
whenever i click Item 'x' i should get a pop up window to enter some value
My question is ...Is it a good idea to display an additional windows form with just a textbox control in it or is there any other better approach in such scenarios ?
Two Ideas-
As #Marcel stated in his comment, you can use a ComboBox with its DropDownStyle set to DropDown (not DropDownList). This will allow a user to select from the list or enter their own value. From there, you can do validation of the value if necessary.
If you need to be more explicit about a custom option (as opposed to the first idea, where it is not entirely obvious that you can enter a custom value), you could have a ComboBox with DropDownStyle set to DropDownList, a TextBox below it, and two RadioButtons that will enable/disable these to make them mutually exclusive.
I err against using popup messages/form whenever possible. I think it makes the application look kind of hacky, IMHO.
you may use a hidden textbox beside the combobox, and show it only if the used selects the Custom item
Related
How do I display Price value($) in textbox next to a label when user checks the radio button, select one of item from listBox, and then clicks the button?
Is there way to do it on the form1.cs[Design] using the properties? Or do I need to set them up in code level?
listBox item example
EDIT: Solved this in Code-level.
I don't think you can do it without any code.
Also I'd recommend you to check out this page - just a few simple rules can make your chances to get a good answer on this site much better.
And there is not much of coding needed to solve your problem. Take a look on the Events tab in Property view in form designer. A few event handlers to process user input and some fields inside your class to store the data - I assume it is not some serious business app you're dealing with, so all the code you need for this to work would be like 20 lines tops -)
I'm new to the C# part of programming, I am currently making a Program that is centered functionally around a ComboBox. In the Combobox, I have a concatenated string that looks like this:
IF checked
("☑ " + client.shortName)
IF unchecked
("☐ " + client.shortName)
So the output would be something like
☐ RealMadrid
As one item in the dropdown list of a comboBox.
My question is, can I implement an event handler that detects when the CheckBox (Not the actual Control Type, more like a character) region of the dropdown is clicked? If yes, Can I get a walk-through on how to do it? (It doesn't have to be a full class, but I would be grateful if It was)
Thanks
Wouldn't you be able to use the SelectedIndexChanged event, then just check the first character of the selected value (string) for '☑' or '☐'?
Edit - I think I understand - you want the user to be able to select the item without changing the checkbox 'checked' property, but also allow them to change it if they click towards the left side of the item. You can check the location of the cursor in relation to the form location and determine which side of the combobox they are selecting. It is not necessarily a clean implementation, but I don't think there's another way to fool the program using controls like that.
Is there a specific reason to be using a ComboBox as opposed to a number of Checkboxes where the text is updated with the client.shortName?
I'm using RadGridview and its FooterRow contains 3 Check Boxes.Now if i want to allow only one checkbox to be checked and the other two should not be allowed to check how should I implement it? i need to implement.
Like the Radio buttons.
Since you can have any controls in a FooterRow, can you not actually use Radio Buttons rather than checkboxes?
If you have a situation where you want to have a checkbox at the foot of each column and only one of those checkboxes can be selected, you probably need to provide a little more information about the intent you are trying to accomplish.
I am trying to look for a simple way to design a winform with a combobox that has checkbox values in it to select multiple values.
But there are no free samples I could find.
If anybody has a good link for a sample which does not require a license.
Please let me know.
I am not looking for controls like telerik and infragistics.
Maybe this example can help you.
CheckBox ComboBox Extending the ComboBox Class and Its Items
It sounds like what you really want is a checked listbox control or maybe even just a listbox. These controls do multi-select in a way that is more standard for Windows.
If you really need a combo box with checkboxes in it, here's an article on code project I used once.
My suggestion, if space is an issue as #rmc00 has eluded to, place a button at the end of a readonly Textbox with perhaps an elipse (...) or down arrow (same as combobox) as the text of the button and when clicked or MouseDown make visible and position a CheckBoxList or open a popup dialog with a CheckBoxList this way you can either prepopulate at design time or pass a DataTable as a parameter/property to your control/form so it is databound at runtime. You can always place your control or write code to position the control/form exactly below your TextBox in the MouseDown/Click event. On check change update your textbox with a comma separated list (or go fancy and say if more than 3 items the text box can have the list stored in the Tag and the TextBox Text can have the count of items checked). Finally on LostFocus hide the Control (or Form), and further if you want to get fancy make the exception to not hide when the ActiveControl is the Button that way you can toggle the visibility of consecutive button presses.
Is it possible to have my comboBox, numericUpDown, and ListBox connected together?
I want to make the numericUpDown to be the limit of the choices that you could made taht will be displayed in the listbox. For example:
If numericUpDown == 2 then,
comboBox == 5 choices. You Can Choose 2. Your first choice shouldn't be included in your second lookthrough of the combobox. then,
listbox == 2. (The listbox should only contain data. Depending on the value of the numericUpDown) So if the user choose again in the combobox the datas in the list box wouldn't be affected.
How might I implement this?
C# has most of the useful controls but sometimes what you need is not there.
You can always make your own controls or just add a little coding to get what you want.
Nothing Is Impossible.
Here is a simple way to make your own Control and then use it in your program.
http://www.codeproject.com/KB/miscctrl/first_control.aspx