C# Combobox to show different lists - c#

I'm a bit stuck on the approach for this task. I want to be able to provide 2 separate lists for one combobox based on a radio button selection.
I'm not looking for the exact code, but rather the approach.
Do I create two lists and make them visible/invisilble based on radio button selection
Do I create 2 arrays and based on radio button selection populate combobox items
Another implementation?
Without showing me the code, what approach would be seen as standard?
Thanks!

The recommended solution is to create 2 arrays and based on the user selection (radio button) populate the list with the appropriate data/items.

Related

How to create a custom selectionmode in winforms listbox

I have a listbox in a winforms application that I would like to give a selection behavior that is different than the built in options for the control.If I choose multi-extended, I get what we are accustomed to - ability to use shift or control to select multiple items in the list. The multi-simple option lets you select individually and leave the item selected until you delect it. I'm trying to deal with a slightly different problem that could be solved by a combination of the two options. My users want to be able to use the shift key to highligh a long list and they don't want to accidentally lose their selection if they mistakenly click on one other item in the list. My thought was to keep everything hightlighted until they click a clear button. I kind of think they are asking for something that is not what Windows is meant to do and should not be allowed to do but I thought would post the question so see if anyone has done this before.

WPF - what is the best way to bind data from a database to a checkbox control

I am struggling some time with checkbox control in WPF. What I am trying is to to make some kind of filter.
1. So first I need to fill the checkbox control with the database items
2. Second I need to check if anything is checked
3. Third if anything is checked I want to take those values and use them to search through the database
4. Should I use only checkbox control for this or should I put it in some container or a listBox?
I have find many topics here that are mentioning this stuff, but I couldn't manage to find the complete answer, only lot of parts that are not compatible with each other. I would really appreciate if someone explain to me how checkbox in WPF works.
If you have multiple values and you want to display multiple CheckBoxes, one for each of them, then you will need to use a ListBox and have the TemplateItem a CheckBox. This way your collection of items is bound to the ListBox, and for each item in the ListBox a CheckBox is shown.
So to get each of the values after there is an additional step if your doing MVVM and don't want to touch the UI. What you do is create a wrapper class that sits around your class and has a extra property for the IsChecked data. This way you can get the checked state without touching the UI.
I have an example of this on my blog:
Checked ListBox in WPF
To check which items are checked you just need a simple LINQ query. So if you use the example there from my blog then you should be able to do something like this:
var checkedCustomers = Customers.Where(w=>w.IsChecked).ToList();

C# ListView items with custom controls

I'm maintaining a C# application written with windows forms. I now need to have a list view where every item has a few custom controls.
Every item need to have title and a combobox. The problem is that the data for the custom boxes will be different. So for example Item 1 could have a ComboBox where you can pick 1-3. Item 2 would have a combo box where you can pick 1-2.
So in the property column I need a string, and in the value column a combobox, with different data sets for different items (or at least for different kinds of items)
I've been on this problem for a while, and I don't really know where to go from here.
Why don't you use a Property Grid control? It is composed by two columns, the left one being a fixed text for the key/title and the right one is dynamic, in the sense you can have comboboxes, textboxes, color selection controls, etc. for the value the user can input/select.

Drop down consists of many items

I am facing weird kinda situation. I have form which consists of 6 Fields among which 1 is drop down list. Now i have filled that drop down from another table but problem is that the Drop Down consists loads many items (ComplaintID) and can extent further. So what can be the solution instead of using Drop down or trimming it or anything.
have you tried a listbox? that lets you scroll so doesn't matter how many items really
Have a look at
Chosen
Autocomplete
Also have a look at
Why drop-down lists are bad for the user experience?
What are the alternatives to a very long dropdown?
Alternatives to huge drop down lists

C# Day from Week picker component

This question is for C# 2.0 Winform.
For the moment I use checkboxes to select like this : Monday[x], Thuesday[x]ΒΈ... etc.
It works fine but is it a better way to get the day of the week? (Can have more than one day picked)
Checkboxes are the standard UI component to use when selection of multiple items is allowed. From UI usability guru Jakob Nielsen's article on
Checkboxes vs. Radio Buttons:
"Checkboxes are used when there are lists of options and the user may select any number of choices, including zero, one, or several. In other words, each checkbox is independent of all other checkboxes in the list, so checking one box doesn't uncheck the others."
When designing a UI, it is important to use standard or conventional components for a given task. Using non-standard components generally causes confusion. For example, it would be possible to use a combo box which would allow multiple items to be selected. However, this would require the user to use Ctrl + click on the desired items, an action which is not terribly intuitive for most people.
checkbox seems appropriate.
You can also use a ListView with CheckBoxes on...
for a little less hard coding.
Checkboxes would work fine, and there is a preexisting paradigm of that usage in Windows Scheduled Tasks. To see that example, create a scheduled task and select Weekly for the frequency.

Categories

Resources