title: DevExpress LookupEdit - setting the selected DataRow by code
body: <p><strong>I am aware that there other questions like this, but their solutions do not work for me.</strong></p>
  <p>I have the following code:</p>
  <blockquote>
  <pre><code>     lueSizes.Properties.DataSource = new BindingSource(PS.PaperSizes, null);
       lueSizes.Properties.Columns.Add(new LookUpColumnInfo(&quot;PaperName&quot;, &quot;Größe&quot;));
       lueSizes.Properties.DisplayMember = &quot;PaperName&quot;;
       lueSizes.Properties.ValueMember = &quot;PaperName&quot;;
  
       //PS is a regular System PrinterSettings object
       foreach (PaperSize size in PS.PaperSizes)
  
           //I confirmed with debugging that this actually happens correctly
           if (size.RawKind == binSettings.SizeRawKind)
            {
                lueSizes.EditValue = size;
                break;
            }
  </code></pre>
  </blockquote>
  <p>Populating the LookupEdit with the DataSource works fine, the user can select the desired PaperSize from the dropdown, and</p>
  <blockquote>
  <p>lueSizes.GetSelectedDataRow() as PaperSize</p>
  </blockquote>
  <p>then returns a PaperSize object as expected.</p>
  <p>The problem I have is setting the EditValue, it simply does nothing. I have verified that at runtime, the DataSource contains all the PaperSize objects in PS.PaperSizes, including the one that is found in the foreach loop. But setting EditValue = size does not cause the selected data row to update accordingly.</p>
  <p>Other variations I have tried are:</p>
  <blockquote>
  <p>lueSizes.EditValue = size.PaperName;</p>
  <p>lueSizes.EditValue = lueSizes.Properties.GetKeyValueByDisplayText(size.PaperName);</p>
  <p>lueSizes.EditValue = lueSizes.Properties.GetKeyValueByDisplayValue(size.PaperName);</p>
  <p>lueSizes.EditValue = lueSizes.Properties.GetKeyValueByDisplayValue(size);</p>
  <p>lueSizes.EditValue = 0;</p>
  </blockquote>
  <p>None of these do anything, the selected datarow remains NULL and displays nothing to the user.</p>
  <p><strong>What else can I try to set the selected DataRow by code?</strong></p>
  <p>Edit:</p>
  <pre><code>    private void lueSizes_EditValueChanged(object sender, EventArgs e)
      {
          object o = lueSizes.EditValue;
          object p = lueSizes.GetSelectedDataRow();
          PaperSize size = o as PaperSize;
          UpdateSize(size);
      }
  </code></pre>
  <p>Object o is the item I have set earlier, the PaperSize size that Ive found in the loop, but object p is null.</p>