473,398 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Question on Windows Application ComboBox

WB
Hi,

How do I programmatically set the default selected value of a ComboBox?

I have a ComboBox "CmbYear" that has the years and I'd like to set it's
default selected value to the current year like so:

CmbYear.SelectedValue = DateTime.Now.Year.ToString();

But it doesn't work and the application doesn't load with any selected value
for CmbYear.

Why's that?
ywb.
Jun 9 '06 #1
2 1151
WB,

The SelectedIndex the most easiest one, if you want to find that than you
can use the FindStringExact before that.

I hope this helps,

Cor

"WB" <WB@discussions.microsoft.com> schreef in bericht
news:91**********************************@microsof t.com...
Hi,

How do I programmatically set the default selected value of a ComboBox?

I have a ComboBox "CmbYear" that has the years and I'd like to set it's
default selected value to the current year like so:

CmbYear.SelectedValue = DateTime.Now.Year.ToString();

But it doesn't work and the application doesn't load with any selected
value
for CmbYear.

Why's that?
ywb.

Jun 10 '06 #2
WB

That worked, thanks!

"Cor Ligthert [MVP]" wrote:
WB,

The SelectedIndex the most easiest one, if you want to find that than you
can use the FindStringExact before that.

I hope this helps,

Cor

"WB" <WB@discussions.microsoft.com> schreef in bericht
news:91**********************************@microsof t.com...
Hi,

How do I programmatically set the default selected value of a ComboBox?

I have a ComboBox "CmbYear" that has the years and I'd like to set it's
default selected value to the current year like so:

CmbYear.SelectedValue = DateTime.Now.Year.ToString();

But it doesn't work and the application doesn't load with any selected
value
for CmbYear.

Why's that?
ywb.


Jun 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Mr. B | last post by:
I've been seeking the solution to this. But can't figure it out (sounds simple enough). When you Populat a ComboBox, you can select the initial displayed items on startup simply by setting the...
20
by: Jack Schitt | last post by:
I thought I was starting to get a handle on Access, until I tried doing something useful...now I'm stuck. I have a DB with two tables - to keep it simple I'll say that one is an Employee File...
2
by: Woody Splawn | last post by:
I have a question about technique with regard to filling drop downs. I have a Winform that has several different tabs and tables associated with it. In an effort to keep the load time small I...
11
by: Doug Bell | last post by:
Hi, I have a problem with a ComboBox bound to a DataView. The ComboBox shows the correct number of rows but instead of the data, each row shows "System.Data.DataRowView" Can someone explain how...
5
by: James P. | last post by:
Hello, For my new Windows application, all I want is to create an initial form to demo to the user to show them how it looks like with some data on it. So I figure the fastest way is to create...
0
by: | last post by:
Hi All. I have a problem with combobox, what I want is when combobox gets focus I need it to show the dropdown list t.This is fine if the user selects the combobox via keystrokes but when the...
0
by: Jake Montgomery | last post by:
I am using .NET 2.0 forms and running on Windows XP SP2. When I have a tooltip on a combo box, and the combo box is expanded (“dropped down”) using the arrow, it will no longer display it’s...
1
by: GS | last post by:
I got a detailed view of bound sql dataset table. what is the best ways to allow user to select values via combobox on some of the table columns? O know a way of using another table from the same...
0
by: pavanip | last post by:
Hi, I am facing problem with combobox in gridview.I have used combobox in gridview and i am binding data to gridview combobox from database. If i click 2 times on combobox then it is showing the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.