user2139876
user2139876

Reputation: 29

SelectedItem ComboBox

Doe anybody know what this means? "Farbe" means colour in German. I'm trying to understand some old code and I can't make sense of this line. cbModule is a Forms.ComboBox.

If IsDBNull(Me.cbModule.SelectedItem("Farbe")) = True Then

Upvotes: 0

Views: 38

Answers (1)

Pikoh
Pikoh

Reputation: 7713

To understand this, you must first find what's the DataSource of the ComboBox filled with. I can only guess, but let's suppose it is a DataTable, so you'll have something like Me.cbModule.DataSource = dataTable. This makes that all the items of the ComboBox are DataRows.

So,what you really have in Me.cbModule.SelectedItem is a DataRow, that has a column called Farbe. This column may contain DBNull, so this code:

If IsDBNull(Me.cbModule.SelectedItem("Farbe")) = True Then

is accessing the DataColumn Farbe of the selected DataRow and checking if it is DBNull.

Hope this make it clear to you and others.

Upvotes: 2

Related Questions