﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Why is this weirdness needed?</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Mon, 08 Jun 2026 23:05:08 GMT</lastBuildDate><ttl>20</ttl><item><title>Why is this weirdness needed?</title><link>http://forum.strataframe.net/FindPost6129.aspx</link><description>I pulled this code form the code that loads a combo/list from an enum (I think).  There is mention of some .NET weirdness that requires this. I'm wondering if you could shed a bit of light on why this is done? (Setting the display member and value member to ZLS, then to their actual values, then setting datasource, then setting them again!)&lt;br&gt;
&lt;br&gt;
[codesnippet]&lt;br&gt;
  Private Sub SetDataSource(ByVal combo As SF.ComboBox _&lt;br&gt;
                          , ByVal DataSource As Object _&lt;br&gt;
                          , ByVal DisplayMember As String _&lt;br&gt;
                          , ByVal ValueMember As String)&lt;br&gt;
    combo.BeginUpdate()&lt;br&gt;
    combo.DataSource = Nothing&lt;br&gt;
    combo.DisplayMember = String.Empty&lt;br&gt;
    combo.ValueMember = String.Empty&lt;br&gt;
    combo.DisplayMember = DisplayMember&lt;br&gt;
    combo.ValueMember = ValueMember&lt;br&gt;
    combo.DataSource = DataSource&lt;br&gt;
    combo.DisplayMember = DisplayMember&lt;br&gt;
    combo.ValueMember = ValueMember&lt;br&gt;
    combo.EndUpdate()&lt;br&gt;
  End Sub&lt;br&gt;
[/codesnippet]</description><pubDate>Wed, 24 Jan 2007 10:52:29 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Why is this weirdness needed?</title><link>http://forum.strataframe.net/FindPost6160.aspx</link><description>Goodness, that must have been a fun one to track down! Thanks for the info!</description><pubDate>Wed, 24 Jan 2007 10:52:29 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Why is this weirdness needed?</title><link>http://forum.strataframe.net/FindPost6143.aspx</link><description>The problem generally occurs when there is an event handler on the combo's SelectedIndexChanged or SelectedValueChanged or other event that fires when the data source on the combo changes (or even if&amp;nbsp;the combo is data-bound and the formatting can throw an exception).&amp;nbsp; If an exception is thrown from within the handler, .NET snuffs the exception (it doesn't ever bubble up) and the ComboBoxItemCollection is never properly populated with the display and value member values.&amp;nbsp; The value member is left as the raw collection object (the DataRowView), not the value of the property on the object.&amp;nbsp; The display member is then set to the ToString() of the raw object, so the combo box is then populated with several "{System.Data.DataRowView}" entries.&amp;nbsp; We added the code to attempt to circumvent the formatting errors that can occur when you set the data source.</description><pubDate>Wed, 24 Jan 2007 09:18:28 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item></channel></rss>