Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Been quiet, been busy

I have not blogged for quite some time.  We have been very cranking out code.  I have learned a ton lately.  Cool stuff I have learned:

App.Config configSections: use these to create custom configSections in your config files.  Then, use one of three framework types to handle the section at runtime.  In our case we are using System.Configuration.DictionarySectionHandler, which returns a HashTable type.  We are storing ComboBox items as name|value pairs (code|code description) inside a custom configSection. 

Filling a ComboBox from a Code's Table:  we store all of our codes|code descriptions is a code's table.  At runtime, to fill a combo box, we simply retrieve the codes for a particualr combobox as Datatable, and then do this:

cbo.DataSource = SyCodeTable

' Set its ValueMember property

cbo.ValueMember = "code"

' Set its DisplayMember property

cbo.DisplayMember = "codedesc"

Where SyCodeTable is a Datatable and "code" and "codedesc" are the column names in the DataTable.  Works like a charm, very generic.

 

 

2 Comments

  • Hello,



    I am involved in a project using VB.Net and have to have a few comboboxes generate information at runtime. What code did you have previously before the three lines of code you mentioned? How is this managed? Is this based on datasets or...? What information would/should go in the table to be shown at runtime?



    Thanks a bunch.



    Karl

  • Your DataSource is any object that implements the IList interface, such as a DataSet object or an Array object. If you build this at runtime, simply set the controls datasource property to your object that implement IList.

Comments have been disabled for this content.