Solved

How to set default value in ComboBox

Posted on 2013-11-04
2
1,500 Views
Last Modified: 2013-11-04
Hello Experts!

I have attached the code snippets below. Basically I am building a ComboBox in code. The box itself is on the window but I am generating all of the contents in code.

ComboBox WPF Control
<ComboBox x:Name="cboReminderTime" Text="Please select an item" HorizontalAlignment="Left" Margin="150,588,0,0" VerticalAlignment="Top" Width="120"/>

Open in new window


ComboBox Population Control (Snippet)
if (intHoursTillEvent >= 24)
            {
                cboReminderTime.Items.Clear();
                cboReminderTime.Items.Add("15 Minutes");
                cboReminderTime.Items.Add("1 Hour");
                cboReminderTime.Items.Add("3 Hours");
                cboReminderTime.Items.Add("6 Hours");
                cboReminderTime.Items.Add("12 Hours");
                cboReminderTime.Items.Add("24 Hours");
                cboReminderTime.Items.Add("Start Now");

            } // closes >= 24 hours

Open in new window


There are many other hour values it will evaluate against. In all of them, the "15 Minutes" option is the first one in the list and the one I want to set as the default.

I am very new to C# and brand new to WPF. I have VB.Net (WinForm) experience so I am picking this up with decent pace, but I am not getting this one. Google is not being the most helpful this morning either (prob my fault).

Thanks for the help guys and gals!
0
Comment
Question by:LouisM1979
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
dustock earned 500 total points
ID: 39621525
you can set the default value with the index.

cboReminderTime.SelectedIndex = 0;

Open in new window

0
 

Author Closing Comment

by:LouisM1979
ID: 39621554
I thought I tried that. >.<.

Thanks for the support!!!
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question