Click here to Skip to main content
16,004,882 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionCombobox problem Pin
Xerox47-Sep-07 1:05
professionalXerox47-Sep-07 1:05 
AnswerRe: Combobox problem Pin
plural7-Sep-07 1:25
plural7-Sep-07 1:25 
GeneralRe: Combobox problem Pin
Xerox47-Sep-07 1:38
professionalXerox47-Sep-07 1:38 
GeneralRe: Combobox problem Pin
Tom Deketelaere7-Sep-07 2:22
professionalTom Deketelaere7-Sep-07 2:22 
GeneralRe: Combobox problem Pin
Xerox47-Sep-07 2:34
professionalXerox47-Sep-07 2:34 
GeneralRe: Combobox problem Pin
Tom Deketelaere7-Sep-07 4:56
professionalTom Deketelaere7-Sep-07 4:56 
GeneralRe: Combobox problem Pin
plural7-Sep-07 2:25
plural7-Sep-07 2:25 
AnswerRe: Combobox problem Pin
Dave Kreskowiak7-Sep-07 5:49
mveDave Kreskowiak7-Sep-07 5:49 
I think the other two guys are a bit off the mark.

Are you saying that you want to show a ComboBox with all of your Town names, have the user pick one of those towns and save its TownId in the Person's record?

You don't have to add each town individually. All you need to do is load the Town data into a DataTable object, then bind the ComboBox to that table. Then, when the user selects a town, you'll have to ID automatically, that you can put into the persons record:
' Get the town data into a DataTable object.  I hope you
' already have the SQL done to do this.

' Bind th e Combo to the Towns DataTable object
ComboBox1.DataSource = townsData

' Tell the ComboBox to display the data in the
' TownName column of your data
ComboBox1.DisplayMember = "TownName"

' Tell the ComboBox to use the value in the
' TownId column as the value to be returned when
' the user selects an item
ComboBox1.ValueMember = "TownId"

Now, when the user selects a town, you can use the value of the TownId
Dim selectedTownId As Integer = ComboBox1.SelectedValue



A guide to posting questions on CodeProject[^]

Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007


GeneralRe: Combobox problem Pin
Xerox49-Sep-07 19:47
professionalXerox49-Sep-07 19:47 
QuestionCan any one help me for image displaying Pin
Senthil S7-Sep-07 1:01
Senthil S7-Sep-07 1:01 
AnswerRe: Can any one help me for image displaying Pin
SHatchard7-Sep-07 2:23
SHatchard7-Sep-07 2:23 
GeneralRe: Can any one help me for image displaying Pin
Tom Deketelaere7-Sep-07 2:28
professionalTom Deketelaere7-Sep-07 2:28 
Questionpop3 client Pin
nicetohaveyou7-Sep-07 0:45
nicetohaveyou7-Sep-07 0:45 
AnswerRe: pop3 client Pin
Vimalsoft(Pty) Ltd7-Sep-07 1:39
professionalVimalsoft(Pty) Ltd7-Sep-07 1:39 
AnswerRe: pop3 client Pin
Dave Kreskowiak7-Sep-07 5:19
mveDave Kreskowiak7-Sep-07 5:19 
QuestionCalling Stored SQL Functions from Visual Basic Pin
Mark Cabbage6-Sep-07 23:08
Mark Cabbage6-Sep-07 23:08 
AnswerRe: Calling Stored SQL Functions from Visual Basic Pin
Colin Angus Mackay6-Sep-07 23:58
Colin Angus Mackay6-Sep-07 23:58 
AnswerRe: Calling Stored SQL Functions from Visual Basic Pin
Duncan Edwards Jones7-Sep-07 2:51
professionalDuncan Edwards Jones7-Sep-07 2:51 
GeneralRe: Calling Stored SQL Functions from Visual Basic Pin
Mark Cabbage8-Sep-07 14:42
Mark Cabbage8-Sep-07 14:42 
Questiona case with checkbox (selected and shadow) Pin
nicetohaveyou6-Sep-07 21:24
nicetohaveyou6-Sep-07 21:24 
AnswerRe: a case with checkbox (selected and shadow) Pin
Tom Deketelaere6-Sep-07 22:05
professionalTom Deketelaere6-Sep-07 22:05 
QuestionSorting Collection with 200000+ Items Pin
MadmanWoo6-Sep-07 21:02
MadmanWoo6-Sep-07 21:02 
AnswerRe: Sorting Collection with 200000+ Items Pin
Tom Deketelaere6-Sep-07 22:11
professionalTom Deketelaere6-Sep-07 22:11 
AnswerRe: Sorting Collection with 200000+ Items Pin
GuyThiebaut6-Sep-07 23:05
professionalGuyThiebaut6-Sep-07 23:05 
GeneralRe: Sorting Collection with 200000+ Items Pin
MadmanWoo10-Sep-07 15:49
MadmanWoo10-Sep-07 15:49 

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.