Solved

Default Value Drop Down List

Posted on 2004-03-25
5
519 Views
Last Modified: 2012-05-04
Hi,

I have a combo setup as a drop down list, defined the values for the list in the collection, how through the properties do I set the first value to be selected.
0
Comment
Question by:Plucka
[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
  • 3
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
culshaja earned 250 total points
ID: 10675553
You need to loop through the items and set the slected property iof the item that you want to be selected be set to true.

James :-)
0
 
LVL 18

Author Comment

by:Plucka
ID: 10675565
Right, if i knew how to do that i'd be half way there :(
0
 
LVL 18

Author Comment

by:Plucka
ID: 10675604
SpeedCombo.SelectedIndex = 0

works but you got me on the right track.
0
 
LVL 7

Expert Comment

by:culshaja
ID: 10675647
Are you using WinForms or ASP.Net?

In Winforms you just use the slectedIndex property i.e.

cboX.SelectedIndex = 2

If you need to loop through it you use the following

        Dim c As Integer
        For c = 1 To cboX.Items.Count - 1
            If CType(cboX.Items(c), String) = myStringVarToCheckAgainst Then
                cboX.SelectedIndex = c
                Exit For
            End If
        Next

In ASP.Net you use the following code:

For intCount = 0 To (objDropDownList.Items.Count - 1)
    If objDropDownList.Items(intCount).Value = myVarToCheckAgainstThen
        objDropDownList.Items(intCount).Selected = True
        Exit For
    End If
Next intCount

Hope this helps

James :-)
0
 
LVL 7

Expert Comment

by:culshaja
ID: 10675657
Sorry about being a little late on the better response .....  :-(

James  :-)
0

Featured Post

Create CentOS 7 Newton Packstack Running Keystone

A bug was filed against RDO for the installation of Keystone v3. This guide is designed to walk you through the configuration for using Keystone v3 with Packstack. You will accomplish this using various repos and the Answers file.

Question has a verified solution.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

622 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