Solved

Default Value Drop Down List

Posted on 2004-03-25
5
498 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
  • 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

786 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