title: DevExpress GridView Scroll Bar (adjusting Grid Left Coord to bring focused column in the center of the grid)
body: <p>I have a form which has a DevExpress GridView. The GridView has close to 100 columns. Currently, at a time I show 30 columns to the user and the rest of the columns can be accessed by scrolling on the right hand side.</p>
  
  <p>Instead of scrolling, I want to implement a functionality such that I enter a value(Column Number) in a textbox and click a button (for example), it should navigate to that particular column in the gridView.</p>
  
  <p>So far, I am able to implement the following:</p>
  
  <ol>
  <li><p>If suppose, in the beginning i show columns 1-30 and search column 45 it shows the result with the column selected at the extreme right.</p></li>
  <li><p>If suppose, in the beginning i have columns 20-50 columns shown to the user and search column 10, it shows in the extreme right.</p></li>
  </ol>
  
  <p>I want to implement in such a way that whenever I search a column, it should not show in the extreme right or left but should show in the center.</p>
  
  <p>Please check the code given below. The logic seems to be fine but it is not working correctly.</p>
  
  <pre><code> private void SetLeftCoord(int toBeFocusedIndex)
      {
          int currLeftEndColIndex = gvVisualizeNextGenSequence.LeftCoord / gvVisualizeNextGenSequence.VisibleColumns[0].Width;
  
          int currRightEndColIndex = currLeftEndColIndex - 1 + GetVisibleColumnCount(gvVisualizeNextGenSequence);
  
          if (toBeFocusedIndex &lt; currRightEndColIndex &amp;&amp; toBeFocusedIndex &gt; currLeftEndColIndex)
          {
              int difference = toBeFocusedIndex - currLeftEndColIndex;
              gvVisualizeNextGenSequence.LeftCoord +=
                  (difference * gvVisualizeNextGenSequence.VisibleColumns[0].Width) -
                  (GetVisibleColumnCount(gvVisualizeNextGenSequence) / 2) * gvVisualizeNextGenSequence.VisibleColumns[0].Width;
          }
          if (toBeFocusedIndex &lt; (GetVisibleColumnCount(gvVisualizeNextGenSequence) / 2) ||
            toBeFocusedIndex &gt; gvVisualizeNextGenSequence.VisibleColumns.Count - (GetVisibleColumnCount(gvVisualizeNextGenSequence) / 2))
          { }
  
          if (toBeFocusedIndex &lt; currLeftEndColIndex)
          { gvVisualizeNextGenSequence.LeftCoord -= (GetVisibleColumnCount(gvVisualizeNextGenSequence) / 2) * gvVisualizeNextGenSequence.VisibleColumns[0].Width; }
  
          if (toBeFocusedIndex &gt; currRightEndColIndex)
          { gvVisualizeNextGenSequence.LeftCoord += (GetVisibleColumnCount(gvVisualizeNextGenSequence) / 2) * gvVisualizeNextGenSequence.VisibleColumns[0].Width; }
  
  
          gvVisualizeNextGenSequence.FocusedColumn = gvVisualizeNextGenSequence.Columns["Column" + toBeFocusedIndex];
  
  
      }
  </code></pre>
  
  <p>Is there any other way to do this?
  "at any point of time, my focused column should be in the center of the grid"</p>
  
  <p>Thanks </p>
  
  <p>Mangesh Vilas Kaslikar </p>