For Programmers: Free Programming Magazines  


Home > Archive > C# > March 2004 > How to place list of columns in ComboBox









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to place list of columns in ComboBox
CSerpent

2004-03-28, 10:29 pm

I have a Customer table with Name, PhoneNumber, and City columns. I
want the words "Name", "PhoneNumber", and "City" listed in a ComboBox
so that the user can choose one of them to sort by, or to search by.
OK.

I can type the strings into the Items collection for the control, but
I thought it would be if they were pulled automatically from my
DataTable object. That way, there would be no chance of mis-typing
the column names, and if I modified the columns I'm placing into the
DataTable, the ComboBox would get updated automatically.

Would this be a good situation for Data Binding?

Or, in code, how would I do this so if a column gets added to the
DataSet (DataTable), later, it automatically goes into the ComboBox?

Example code appreciated. Thanks!
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com