Click here to Skip to main content
15,920,596 members
Home / Discussions / C#
   

C#

 
AnswerRe: help to create a dll Pin
Heinz_18-Sep-05 8:02
Heinz_18-Sep-05 8:02 
Questionremoting basics Pin
g00fyman17-Sep-05 21:04
g00fyman17-Sep-05 21:04 
QuestionHoe To increase Row Height of a List View control! Pin
majidbhutta17-Sep-05 19:49
majidbhutta17-Sep-05 19:49 
AnswerRe: Hoe To increase Row Height of a List View control! Pin
mav.northwind17-Sep-05 23:00
mav.northwind17-Sep-05 23:00 
QuestionCrystal report Pin
Amir Jalaly17-Sep-05 19:46
Amir Jalaly17-Sep-05 19:46 
QuestionTyped DataSet Pin
Taurian11017-Sep-05 16:39
Taurian11017-Sep-05 16:39 
QuestionWindows DataGrid Pin
Taurian11017-Sep-05 16:32
Taurian11017-Sep-05 16:32 
QuestionDatabound ComboBox Selection Problems Pin
Glenn E. Lanier II17-Sep-05 13:46
Glenn E. Lanier II17-Sep-05 13:46 
I am displaying a ComboBox that hopefully contains the contents of a database table (a lookup of sorts). When the form loads, the ComboBox contains the correct values, all sorted. Smile | :)

However, when I try to select a value programitically, I can't (well, I can't select the correct one). Frown | :(

I create a dataset:
DataSet dsTitles = new DataSet("Titles");<br />
SqlCommand tableCommand = new SqlCommand();<br />
tableCommand.CommandText = "select TitleID, TitleDisplayText FROM tblTitles WHERE TitleHidden <> 1";<br />
<br />
SqlDataAdapter adapter = new SqlDataAdapter();<br />
adapter.SelectCommand = tableCommand;<br />
adapter.Fill(dsTitles, "Titles"); 


I then bind the dataset to the ComboBox:
comboBoxTitle.BeginUpdate();<br />
comboBoxTitle.DataSource = db.DataSetTitles.Tables["Titles"];<br />
comboBoxTitle.DisplayMember = "TitleDisplayText";<br />
comboBoxTitle.ValueMember = "TitleID";<br />
comboBoxTitle.EndUpdate();


So far, all is well. However, I can't seem to select the correct item. I've tried:
comboBoxTitle.SelectedValue = 2;<br />
Console.WriteLine("Current Title Index: {0} Text: {1} Combo Index: {2} Value: {3} Text: {4}", 2, db.LookupValueTitle(2), comboBoxTitle.SelectedIndex, comboBoxTitle.SelectedValue);<br />


TitleID of 2 matches TitleDisplayText of Mr, but nothing is visibily selected.

Current Title Index: 2 Text: Mr Combo Index: 0 Value: 2 Text: 
is what gets logged.

Any help would be appreciated.

--G Confused | :confused:
QuestionAdding SMP Support Pin
Heinz_17-Sep-05 11:23
Heinz_17-Sep-05 11:23 
AnswerRe: Adding SMP Support Pin
Dave Kreskowiak17-Sep-05 14:37
mveDave Kreskowiak17-Sep-05 14:37 
GeneralRe: Adding SMP Support Pin
Heinz_18-Sep-05 8:09
Heinz_18-Sep-05 8:09 
GeneralRe: Adding SMP Support Pin
Dave Kreskowiak19-Sep-05 1:33
mveDave Kreskowiak19-Sep-05 1:33 
GeneralRe: Adding SMP Support Pin
Heinz_19-Sep-05 10:45
Heinz_19-Sep-05 10:45 
GeneralRe: Adding SMP Support Pin
Heinz_19-Sep-05 11:27
Heinz_19-Sep-05 11:27 
GeneralRe: Adding SMP Support Pin
Dave Kreskowiak19-Sep-05 15:24
mveDave Kreskowiak19-Sep-05 15:24 
GeneralRe: Adding SMP Support Pin
Heinz_19-Sep-05 17:10
Heinz_19-Sep-05 17:10 
QuestionMoving xml nodes Pin
thepersonof17-Sep-05 9:53
thepersonof17-Sep-05 9:53 
AnswerRe: Moving xml nodes Pin
Alomgir Miah17-Sep-05 11:02
Alomgir Miah17-Sep-05 11:02 
AnswerRe: Moving xml nodes Pin
Heinz_17-Sep-05 11:12
Heinz_17-Sep-05 11:12 
AnswerRe: Moving xml nodes Pin
DavidNohejl17-Sep-05 14:19
DavidNohejl17-Sep-05 14:19 
QuestionMDI menu merge prevention Pin
thrakazog17-Sep-05 9:41
thrakazog17-Sep-05 9:41 
AnswerRe: MDI menu merge prevention Pin
thrakazog18-Sep-05 5:03
thrakazog18-Sep-05 5:03 
QuestionCsGL - using CsGL.Basecode; Pin
Anonymous17-Sep-05 9:25
Anonymous17-Sep-05 9:25 
QuestionXML Problem Pin
thepersonof17-Sep-05 8:24
thepersonof17-Sep-05 8:24 
QuestionGetting a Regular Expression that matches a grop of files Pin
hyperreview17-Sep-05 6:33
hyperreview17-Sep-05 6:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.