<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Exploring DataGridViewComboBoxColumn databinding (part2)</title>
	<atom:link href="http://www.timvw.be/exploring-datagridviewcomboboxcolumn-databinding-part2/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.timvw.be/exploring-datagridviewcomboboxcolumn-databinding-part2/</link>
	<description>The journey of a thousand miles begins with one step.</description>
	<lastBuildDate>Fri, 02 Jul 2010 13:49:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: timvw</title>
		<link>http://www.timvw.be/exploring-datagridviewcomboboxcolumn-databinding-part2/comment-page-1/#comment-42000</link>
		<dc:creator>timvw</dc:creator>
		<pubDate>Fri, 27 Jun 2008 05:58:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.timvw.be/exploring-datagridviewcomboboxcolumn-databinding-part2/#comment-42000</guid>
		<description>&lt;p&gt;The problem is that when the dropdownlist is shown, it selects the first value (a geeky person). As soon as you click on a different dropdown, that &#039;new&#039; selection is committed (thus, the person becomes a geek), which explains why the next time the dropdown list is different.

Here is an implementation that does not have that unwanted behaviour:
&lt;/p&gt;

[code lang=&quot;csharp&quot;]
void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
 if (this.dataGridView1.CurrentCell.ColumnIndex == this.ColumnPersonTypeCode.Index)
 {
  BindingSource bindingSource = (BindingSource)this.dataGridView1.DataSource;
  PersonsDataSet.PersonRow person = (PersonsDataSet.PersonRow)((DataRowView)bindingSource.Current).Row;
  PersonsDataSet.PersonTypeDataTable personTypeDataTable = DataSetDac.FindPersonTypes(person);

  DataGridViewComboBoxEditingControl comboBox = (DataGridViewComboBoxEditingControl)e.Control;
  comboBox.DataSource = personTypeDataTable;
  // force the combobox to pick up the correct value.
  comboBox.SelectedValue = person.PersonTypeId;

  comboBox.SelectionChangeCommitted -= this.comboBox_SelectionChangeCommitted;
  comboBox.SelectionChangeCommitted += this.comboBox_SelectionChangeCommitted;
 }
}[/code]

&lt;p&gt;I&#039;ll post an updated zip package as soon as i&#039;m able to setup an ftp connection.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;EDIT 28/06/2008&lt;/b&gt;: I&#039;ve uploaded (and overwritten) the zip file with the modification.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>The problem is that when the dropdownlist is shown, it selects the first value (a geeky person). As soon as you click on a different dropdown, that &#8216;new&#8217; selection is committed (thus, the person becomes a geek), which explains why the next time the dropdown list is different.</p>
<p>Here is an implementation that does not have that unwanted behaviour:
</p>
<pre class="brush: csharp;">
void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
 if (this.dataGridView1.CurrentCell.ColumnIndex == this.ColumnPersonTypeCode.Index)
 {
  BindingSource bindingSource = (BindingSource)this.dataGridView1.DataSource;
  PersonsDataSet.PersonRow person = (PersonsDataSet.PersonRow)((DataRowView)bindingSource.Current).Row;
  PersonsDataSet.PersonTypeDataTable personTypeDataTable = DataSetDac.FindPersonTypes(person);

  DataGridViewComboBoxEditingControl comboBox = (DataGridViewComboBoxEditingControl)e.Control;
  comboBox.DataSource = personTypeDataTable;
  // force the combobox to pick up the correct value.
  comboBox.SelectedValue = person.PersonTypeId;

  comboBox.SelectionChangeCommitted -= this.comboBox_SelectionChangeCommitted;
  comboBox.SelectionChangeCommitted += this.comboBox_SelectionChangeCommitted;
 }
}</pre>
<p>I&#8217;ll post an updated zip package as soon as i&#8217;m able to setup an ftp connection.</p>
<p><b>EDIT 28/06/2008</b>: I&#8217;ve uploaded (and overwritten) the zip file with the modification.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bob</title>
		<link>http://www.timvw.be/exploring-datagridviewcomboboxcolumn-databinding-part2/comment-page-1/#comment-41968</link>
		<dc:creator>Bob</dc:creator>
		<pubDate>Thu, 26 Jun 2008 19:16:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.timvw.be/exploring-datagridviewcomboboxcolumn-databinding-part2/#comment-41968</guid>
		<description>bug?

thanks for this, but I found it doens&#039;t work correctly. here is what I did.


1. click on first &quot;persontypecode&quot; dropdown, it is correct.
2. click on second one, and it shows corrrect.
3. click on the first dropdown again, it is good.
4. slick on second one again. the list is wrong, it shows as the first one. 
and so on. to 3rd and 4th..etc

PS. don&#039;t change the value for each drop down.

thanks!</description>
		<content:encoded><![CDATA[<p>bug?</p>
<p>thanks for this, but I found it doens&#8217;t work correctly. here is what I did.</p>
<p>1. click on first &#8220;persontypecode&#8221; dropdown, it is correct.<br />
2. click on second one, and it shows corrrect.<br />
3. click on the first dropdown again, it is good.<br />
4. slick on second one again. the list is wrong, it shows as the first one.<br />
and so on. to 3rd and 4th..etc</p>
<p>PS. don&#8217;t change the value for each drop down.</p>
<p>thanks!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
