The text of this article is not in this database — only its details are. Read it on the old site: WPF ComboBox
43 Comments
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.
The text of this article is not in this database — only its details are. Read it on the old site: WPF ComboBox
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.
ca ThichPosted Jun 17, 2022, 7:53 PM
How can I create a combobox with pre-defined static items to be able to use in different xaml? Thanks
rakesh vPosted Jun 25, 2019, 5:59 AM
WPF (not using MVVM) I have a list of Items ex. 1,2,3,4,5,6 . I was added this list to combobox from code behind. I have grid with rows(AllUsers and SomeUsers related data), When I click on AllUsers data row then in selection changed i was adding 1,2,3,4,5,6 through item source from code behind. when I click on SomeUsers data row then in selection changed i was adding 2,5,6 through itemsource from code behind. Here I was using observable collection for grid data and combobox(it is sub list of observable collection). Combobox is in outside the grid. What ever data is selected in combobox it will automatically updated to my grid model(i was using two way binding in combobox). Problem :- when selection changed happens I was adding relevant data to combobox through Item source from code behind , at that time previously selected value is getting null in the model property(especailly 'AllUsers' data when property contains 1 or 3 or 4 values because those are not exist in combobox list of SomeUsers data
MaicoLinuX JJeyPosted Dec 6, 2018, 6:28 PM
Is possible to add and delete items with images dinamically?
aparichitudu againPosted Apr 24, 2018, 2:34 AM
How to bind seleted value to static vales
aparichitudu againPosted Apr 24, 2018, 2:33 AM
How to bind selected value to that static list,Ex I need to make "Tea" as selected item in dynamically
vijay rajPosted Dec 20, 2017, 11:34 PM
Is it possible to scroll through the values of combo box without having to use scroll bar, can i simply scroll the values using touch. or is there an alternate component for doing such things
Ramesh PalaniappanPosted Sep 7, 2016, 11:56 AM
Good one
Dinesh BeniwalPosted Jun 29, 2014, 1:26 PM
Good article
Nilesh AvhadPosted Jun 16, 2014, 6:44 AM
Nice Article Mahesh!! You always rocks :)
Sourabh SomaniPosted Jun 15, 2014, 2:49 PM
Very Nice article sir
Divya SharmaPosted Jun 15, 2014, 2:27 PM
nice article sir
Mahesh ChandPosted Jun 15, 2014, 1:41 PM
Thank for the comments guys
Praveen kumarPosted Jun 9, 2014, 3:14 AM
i understand the code, if i work means i didn't get the output please tell some ideas how to develop the coding knowledge
Musa AjPosted Nov 6, 2012, 4:53 AM
Nice very Useful for beginners......
Meir GalperinPosted Jul 29, 2012, 4:47 PM
Thank you for this useful article
Mahesh ChandPosted Jun 25, 2012, 10:15 AM
Thanks Garcia. Please feel free to add your code sample to the article by Adding it at the bottom "Add an Article Extension". and that will add your code at the bottom. thank you!
Marcus GarciaPosted Jun 25, 2012, 9:19 AM
Well, if somebody needs here is the code that worked for me:<code> ////ItemTemplate Style estilo = new Style(); estilo.TargetType = typeof(ComboBoxItem); estilo.Setters.Add(new Setter(ComboBoxItem.ForegroundProperty, item.Foreground.SelectedBrush)); comboBoxFactory.SetValue(ComboBox.ItemContainerStyleProperty, estilo); comboBoxFactory.SetValue(ComboBox.ForegroundProperty, item.Foreground.SelectedBrush); </code>
kalikrishna maddulaPosted Jun 25, 2012, 7:31 AM
Good article.....
Marcus GarciaPosted Jun 14, 2012, 8:12 AM
Hey man, very good tutorial!! Let me make a question... how do I color the Items in the combobox direct in the code? I tried this: <code> var dtFact = new FrameworkElementFactory(typeof(TextBlock)); dtFact.SetBinding(TextBlock.TextProperty, new Binding(String.Format("[{0}]", item.GetHashCode()))); comboBoxFactory.SetValue(ComboBox.ItemTemplateProperty, new DataTemplate { VisualTree = dtFact }); </code> but it Didn't work.. t.i.a. Marcus.
Mahesh ChandPosted May 30, 2012, 10:27 AM
Gangadhar, I would say, just go to WPF section of this site and read my articles one by one. I have written ton of articles on WPF and they are very easy to follow. Good luck!
Gangadhar MahindrakareditedPosted May 14, 2012, 7:03 AMEdited May 14, 2012, 7:18 AM
Thanks, i am just now learning the wpf, but i am not getting.please help me understanding the wpf.
paul ramsdenPosted Jul 13, 2011, 4:21 AM
"Text property of ComboBox represents the text of the current selected item in a ComboBox" Text is the contents of the TextBox part and is not necessarily in the ComboBox item list. It may therefore differ from the selected item
Kate MilantievaPosted Jul 10, 2011, 10:15 AM
thank you! such a useful article
shriram iyerPosted Feb 17, 2011, 3:54 AM
how do i display the selected item from a combobox in a separate textbox
Showken YipPosted Jan 22, 2011, 10:18 AM
Great Article!!
Michael PellegriniPosted Nov 4, 2010, 9:02 AM
private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e) { // Declaration ComboBox cbox = new ComboBox(); // Properties cbox.Name = "comboBox1"; cbox.Width = 120; cbox.Height = 123; // Combo Box Items ComboBoxItem item = new ComboBoxItem(); item.Content = "Arizona Cardinals"; cbox.Items.Add(item); cbox.Items.Add("Atlanta Falcons"); cbox.Items.Add("Baltimore Ravens"); cbox.Items.Add("Buffalo Bills"); cbox.Items.Add("Carolina Panthers"); cbox.Items.Add("Chicago Bears"); cbox.Items.Add("Cincinnati Bengals"); cbox.Items.Add("Cleveland Browns"); cbox.Items.Add("Dallas Cowboys"); cbox.Items.Add("Denver Broncos"); cbox.Items.Add("Detroit Lions"); cbox.Items.Add("Green Bay Packers"); cbox.Items.Add("Houston Texans"); cbox.Items.Add("Indianapolis Colts"); cbox.Items.Add("Jacksonville Jaguars"); cbox.Items.Add("Kansas City Chiefs"); cbox.Items.Add("Miami Dolphins"); cbox.Items.Add("Minnesota Vikings"); cbox.Items.Add("New England Patriots"); cbox.Items.Add("New Orleans Saints"); cbox.Items.Add("New York Giants"); cbox.Items.Add("New York Jets"); cbox.Items.Add("Oakland Raiders"); cbox.Items.Add("Philadelphia Eagles"); cbox.Items.Add("Pittsburgh Steelers"); cbox.Items.Add("San Diego Chargers"); cbox.Items.Add("San Francisco 49ers"); cbox.Items.Add("Seattle Seahawks"); cbox.Items.Add("St Louis Rams"); cbox.Items.Add("Tampa Bay Buccaneers"); cbox.Items.Add("Tennessee Titans"); cbox.Items.Add("Washington Redskins"); } } } Ive programmed the above, but for some reason the items are not appearing in the combo box when i run the problem. why is this, please help me!
Ilya TsilikovPosted Sep 23, 2010, 9:32 AM
I want to note that the proposed definition of ComboBox items is no good at all. Such items don't display properly. You can check it.
ashish patelPosted Aug 12, 2010, 6:14 AM
damn cool artical..
EugenPosted Jun 9, 2010, 10:49 AM
but how to bind with sql??? give an exaple pls))
EugenPosted Jun 9, 2010, 10:45 AM
Great article!!!