Visual C# Combobox - winforms

Is it possible if I choose 2 in my numericupdown control I will also have 2 comboboxes??
It's that the comboboxes that will appear will vary from the value of my numericupdown button.
Or Maybe I'm thinking if i input 5 in my numeric updown I will have the choose 5 datas in my combobox and my choices will be stored in a listbox.
Because I'm making a room assignment. for example a customer wishes to rent 5 rooms I should assign him with 5 available rooms. And I want my rooms assignment to be recorded in a listbox so that I can keep track of my mistakes.. Is it Possible??
If my question violated the rule, can somebody just please post links related to this problem. I know I'm a bit annoying to this site and I am very sorry :((

I'm going to take some guesses as to what you are trying to do as it isn't very clear from your question.
If you are asking:
Is it possible to create a Windows Forms dialog which dynamically
displays n ComboBox controls at runtime based on a user supplied
value from a NumericUpDown control?
Then the answer, is: Yes, it's possible. There are several ways to accomplish this, although the simplest would probably be to use one of the layout panels, possibly the TableLayoutPanel or the FlowLayoutPanel. Essentially, you would need to respond to the (probably) the ValueChanged event on the NumericUpDown control. In that event handler, you would then need to programatically create the appropriate number of ComboBox controls (based on the value of the NumericUpDown control) and add them to the layout panel.

Related

WPF Datagrid with similar Outlook 2013 mail list style

I am new to WPF. I want to design a Datagrid similar to mail list in outlook 2013 having same style and features.
In outlook 2013, Datagrid template changes when its width decreases and goes to one liner type of mode when it expands.
I tried to implement this behavior with two separate Datagrid controls (only one control will be visible at a time), however, I faced lot of issues. Changes occurred in one grid have to reflect on other grid. I think its an indirect method. Can I achieve this by using single control.
I am not sure if you are familiar with Triggers, however I would suggest you to apply a Trigger to your Style based on the control's width property and change it's style the way you wish to be.
Here is a very good tutorial about Templates and Triggers from Josh Smith that you can learn from. In fact, have a look at all the parts of this tutorial if you want to learn more about WPF best practices.
A Guided Tour of WPF – Part 4 (Data templates and triggers)
Meanwhile since you're looking for a Trigger value to be a range rather than a certain value, say (Pseudo) Trigger when ListView's width < 300, you will need to use a custom converter with your trigger.
For an example of such converter look into this question
WPF Trigger when property value is greater than a certain amount

Want to style the comboboxes and scroll bars in my application

I've got Expression Blend 4 installed on my machine. I just need to know what I'm doing.
My application will be running on a laptop equipped with a touch screen, in police cars where the user will probably be driving the car. Needless to say, the interface has to be easy to use. In this case, that means things like the drop down buttons on ComboBox controls and scroll bars need to be wider than normal so they're easy for the driver to use.
Can someone tell me what part I have to change for each of these controls in order to get the effect I want? I tried editing a copy of the template for one of the combobox controls in one of my user controls and playing with the ToggleButton control but that didn't do what I wanted it to do. There's so much mark-up in the template it's hard to tell what's doing what.
Thanks for any help you can give.
Tony
Edit:
I figured it out from the first answer to this previous StackOverflow post. I had to make a copy of the ComboBox's style, then make a copy of the ToggleButton's style.
Thanks anyway.
Tony
The solution was to edit the application in Expression blend. I clicked on one of the ComboBoxes and right clicked. From the context menu, I selected Edit Template | Edit a copy. In the dialog box that appears, I specified that the new template should be applied to all ComboBoxes in the application.
Within the ComboBox's style, there's a ToggleButton. I repeated the above steps with the Togglebutton. Finally, I changed the width to make it what I wanted. There's also a path in there for the arrow that you can play with if you like.
Tony

Using MVVM to Solve Combobox Interaction

I'm new to WPF and I haven't used MVVM yet but I think I'm in a situation where it might help.
In my program I've got several comboboxes that all have the same comboboxitems and when the user makes a selection in one of the comboboxes the selected comboboxitem gets disabled in the other comboboxes. (i.e. If the user has selected the comboboxitem with value 'a' in combobox #1 and selected the comboboxitem with value 'b' in combobox #2 then in remaining comboboxes both the comboboxitems with values 'a' and 'b' are disabled)
Anyway, I'm having trouble doing this programmatically in the code-behind and I was hoping someone could describe how to approach this problem using MVVM.
Thanks
MG
Here is one of the best primers on MVVM applied to WPF, with first rate code.
It isn't a quick read, and don't get frustrated if even seemingly simple things take some time to grok.
To answer your question more directly, you use MVVM to make data binding work (not to mention your logic testable). So for a ComboBox, you firstly supply it with data. probably using an ObservableCollection which has support for data binding in it. You can synchronize the Selected Item(s) in the ComboBox(es) to a property(ies) in your view model, and change the contents of one based on a change in the Selected Item.
Suggest you read that article and work through some code, then follow up with some more targeted questions using code.
HTH,
Berryl

Silverlight How to load a usercontrol in a page based upon a listbox selection

I am trying to work though the best approach to accomplish the following. Within a page I have it divided into two section. On the left a listbox and the right is empty. (Grid etc). What I would like to accomplish is when an item is selected from the listbox a different user control loads in the right panel. For example if I have three items (one, two three) selecting one would load a red user control, two would load a blue user control and three a green user control.
I was taking this approach since Content Template / Data template selectors are not available in SL. However if anyone has another suggestion I would be grateful for your thoughts.
I'm creating this with MVVM in mind and traditionally I have managed this within the code behind of the user control however I have seen mention of how this could be managed within the ViewModel as well.
Any suggestions or guidance on a best approach is always appreciated.
Cheers
You can bind both listbox selected item and user control visibility properties to the same property in the viewModel.
Then just use a valueConverter for each user control to switch on/off the visibility.
Please tell me if i should elaborate/add a code sample.

textbox, combobox in WPF listview

I am porting an application from foxpro to C#.Net. This is a wine shop billing software. Its billing interface screenshot link is here http://picasaweb.google.com/raj.kishor09/RAJK?feat=directlink
But my client wants similar interface on WPF too. I think listview can help me in this regard but don't know how to implement. i figured out that each row of listview should have 2 textbox, 1 combobox and few textblock or label.
Not only this but cursor should jump from one control to other control using "Enter/Return" key instead of "Tab" key.
Please help me with some code lines.
Please guys help me......
You could use the ListView like you mention. it's not that hard.
Consider this :
You listview will now contains 2 textboxes. I suggest you test a little with something like this. The key point is to define your ItemsTemplate the way you need it.

Resources