Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 27th, 2004, 05:40 AM
Authorized User
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default SelectedItem in ComboBox


I want to select a value from a combobox, in the way:

cb.SelectedItem = "number 2";

But it doesn't work.

I was trying to explore the contents:

sString = cb.Items[i].ToString();

But the values I obtain are always "System.Data.DataRowView" for each element.

Any help?

World only exists into your mind.
Old September 28th, 2004, 06:50 PM
Kep Kep is offline
Authorized User
Join Date: Aug 2003
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts

Try cb.DropDownStyle = ComboBoxStyle.DropDownList and cb.SelectedItem = "number 2".

Otherwise if you just want to change the displayed text use cb.Text = "number 2";


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listview SelectedItem Apocolypse2005 Visual Basic 2005 Basics 1 October 28th, 2007 01:08 PM
Filling Combobox with value from other Combobox ayazhoda Access VBA 6 June 5th, 2007 04:58 AM
Can't EASILY set cbo.selecteditem using VALUE Ron Howerton Visual Basic 2005 Basics 5 December 14th, 2006 04:52 PM
Listbox selecteditem to string Alcapone C# 2 October 28th, 2004 02:18 AM
SelectedItem.Value vs. SelectedItem.Text bekim BOOK: Beginning ASP.NET 1.0 2 June 17th, 2004 07:23 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.