title: Problem with the DevExpress XtraGridView control
body: <p>I have one <code>xtragrid control on my devxpress form</code> .  I've created the <code>columns of my grid at runtime when i load the form</code> . I'm developing the Field chooser for my grid view which is situated on the same form. For that i used the <code>repositoryItemCheckedComboBoxEdit</code>control &amp; in that control i added the column names which will be present in the xtragrid.</p>
  
  <p>Basically i created the columns to the xtragrid with the Visible property to false. When user checks particular column name by using repositoryItemCheckedComboBoxEdit  then i set the Visible to true &amp; again if user unchecked the column name then again i set the visible to false. &amp; while creating column i set the width of the column. </p>
  
  <p><code>Problem which i'm facing is that if user select the all fields from the repositoryItemCheckedComboBoxEdit  then the grid control should show the horizontal scroll bar automatically when require.</code></p>
  
  <p><code>And another problem is that with the columns is besides setting the width of the column, it is not showing the required width of that column . it shrinks that all column width .</code></p>
  
  <p>code which i use for creating column to the xtragridview at run time is as follows -</p>
  
  <pre><code> public void AddGridColumn(string fieldName, string caption, int nRowWidth, RepositoryItem Item, object oCollection, string DisplayMember, string ValueMember, string format, FormatType type)
          {
              DevExpress.XtraGrid.Columns.GridColumn column = ColumnView.Columns.AddField(fieldName);
              column.Caption = caption;
              column.ColumnEdit = Item;
              column.DisplayFormat.FormatType = type;
              column.DisplayFormat.FormatString = format;
              column.VisibleIndex =  ColumnView.VisibleColumns.Count;
              column.Width = nRowWidth;
          }
  </code></pre>
  
  <p>code for the <code>field chooser</code> is as follows - 
  I used this function for filling the items of the repositoryItemCheckedComboBoxEdit  control</p>
  
  <pre><code>private void FieldCollection()
      {
          allFields = new ArrayList();
          columnNames = new Dictionary&lt;string, string&gt;();
          allFields.Clear();
          repositoryItemCheckedComboBoxEdit1.Items.Clear();
          for (int i = 0; i &lt; gvBase.Columns.Count; i++)
          {
              allFields.Add(gvBase.Columns[i].Caption );
              if (gvBase.Columns[i].FieldName != "ContactID")
              {
                  if (gvBase.Columns[i].Visible == true)
                  {
                      if (gvBase.Columns[i].Caption != "Label1" &amp;&amp; gvBase.Columns[i].Caption != "Label2" &amp;&amp; gvBase.Columns[i].Caption != "Label3" &amp;&amp; gvBase.Columns[i].Caption != "Label4" &amp;&amp; gvBase.Columns[i].Caption != "Label5")
                          repositoryItemCheckedComboBoxEdit1.Items.Add(gvBase.Columns[i].Caption, CheckState.Checked);
                      if (!columnNames.ContainsKey(gvBase.Columns[i].Caption))
                          columnNames.Add(gvBase.Columns[i].Caption, gvBase.Columns[i].FieldName);
                  }
                  else
                  {
                      if (gvBase.Columns[i].Caption != "Label1" &amp;&amp; gvBase.Columns[i].Caption != "Label2" &amp;&amp; gvBase.Columns[i].Caption != "Label3" &amp;&amp; gvBase.Columns[i].Caption != "Label4" &amp;&amp; gvBase.Columns[i].Caption != "Label5")
  
                          repositoryItemCheckedComboBoxEdit1.Items.Add(gvBase.Columns[i].Caption, CheckState.Unchecked);
                      if (!columnNames.ContainsKey(gvBase.Columns[i].FieldName))
                          columnNames.Add(gvBase.Columns[i].Caption, gvBase.Columns[i].FieldName);
  
                  }
              }
          }
          cmbFieldChooser.EditValue = "";
      }
  </code></pre>
  
  <p>this is used for the repositoryItemCheckedComboBoxEdit control event - </p>
  
  <pre><code>private void cmbFieldChooser_EditValueChanged(object sender, EventArgs e)
          {
              ArrayList temp = new ArrayList();
              temp.AddRange(allFields);
  
              string[] strFields = cmbFieldChooser.EditValue.ToString().Split(',');
              for (int i = 0; i &lt; strFields.Length; i++)
              {
                  if (temp.Contains(strFields[i].Trim()))
                      temp.Remove(strFields[i].Trim());
                  if (strFields[i] != "")
                  {
                      if (columnNames.ContainsKey(strFields[i].Trim()))
                      {
                          if (gvBase.Columns[columnNames[strFields[i].Trim()]].Visible == false)
                          {
                              gvBase.Columns[columnNames[strFields[i].Trim()]].Visible = true;
                              gvBase.Columns[columnNames[strFields[i].Trim()]].BestFit();
  
                          }
                      }
                  }
              }
              if (temp.Count &lt; 20)
              {
                  for (int j = 0; j &lt; temp.Count; j++)
                  {
                      if (columnNames.ContainsKey(temp[j].ToString().Trim()))
                      {
                          gvBase.Columns[columnNames[temp[j].ToString().Trim()]].Visible = false;
                      }
                  }
              }
              cmbFieldChooser.EditValue = repositoryItemCheckedComboBoxEdit1.GetCheckedItems();
              if ((cmbFieldChooser.EditValue.ToString()).Split(',').Length &gt; 5)
              {
                  gvBase.OptionsView.ColumnAutoWidth = false;
                  gvBase.BestFitColumns();
                  gvBase.HorzScrollVisibility = ScrollVisibility.Always;
              }
              else
              {
                  gvBase.OptionsView.ColumnAutoWidth = true;
                  gvBase.HorzScrollVisibility = ScrollVisibility.Never;
              }
  
          }
  </code></pre>
  
  <p>How to resolve this problem? </p>
  
  <p>thanks.</p>