Ticket T194782
Visible to All Users

Problem focusing cell and ShowEditor in a grid

created 10 years ago

Hi,

I'm using FocusedRowChanged to trap when a record is selected in a grid.

When this happens I want to focus a specific column/cell and show it's editor, which I'm  doing with :

MatchGrid.DefView.FocusedColumn = MatchGrid.DefView.Columns["Allocate"];
            MatchGrid.DefView.ShowEditor();

This works fine when the moving up and down the grid using the up/down keys. However when you just click on a different row with the mouse it doesn't work.

Should I be handling a different event to achieve what I need ?

Cheers,
Phil.

Comments (2)
DevExpress Support Team 10 years ago

    Hello,

    As I understand, you want to change the column to the desired one and launch an editor irrespective of whether the user has selected another column. Correct me if I'm wrong.
    To achieve your goal, handle the GridView.ShowingEditor event and check if it's not the column that you need and cancel the editor display in this case:

    C#
    void gridView1_ShowingEditor(object sender, CancelEventArgs e) { if (gridView1.FocusedColumn != gridView1.Columns["Name"]) e.Cancel = true; }

    I'm looking forward to your response.

      Hi,
      No, in my grid all the other columns are readonly, there are no other active editor fields. My issue is that I am catching FocusedRowChanged, the idea being that when a new record is selected (by any method) that the "Allocate" column be focused, and it's associated editor be shown.
      I don't just want to cancel other editors (as there are none), I want to ALWAYS force focus to the Allocate column and show its editor.
      Hope that clarifies.
      Cheers,
      Phil.

      Answers approved by DevExpress Support

      created 10 years ago (modified 10 years ago)

      Hello,
      Thank you for the clarification. To avoid the issue, show an editor through the BeginInvoke method as follows:

      C#
      void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { gridView1.GridControl.BeginInvoke(new MethodInvoker(() => { gridView1.FocusedColumn = gridView1.Columns["Info"]; gridView1.ShowEditor(); }));

      I hope this helps.

        Comments (3)

          Thanks that works perfectly.
          Phil.

          DevExpress Support Team 10 years ago

            You are welcome. Please contact us if you need further assistance.

              Thanks for the solution! I was looking for hours for this functionality…

              Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

              Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.