Lost Focus RadGridView After Change Cell

12 posts, 0 answers
  1. Alex
    Alex avatar
    3 posts
    Member since:
    May 2011

    Posted 20 May 2011 Link to this post

    Hi, I would like to know how could specify the focus in the next cell of the grid after pressing tab control, I am using Telerik controls in 2009, in which event should I do.

    Thank you.
  2. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 21 May 2011 Link to this post

    Hello Alex,

    Sorry, but this behavior does not occur on the newer versions of the grid and sadly i do not have an older version to find a solution for you...
    But may i suggest looking for a property something like TabBehavior or NormalTabBehavior or something like that, if i remember correctly there was something like that before.

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga

    Telerik WinForms MVP
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Svett
    Admin
    Svett avatar
    728 posts

    Posted 25 May 2011 Link to this post

    Hi Alex,

    This is the default behavior of RadGridView. You should verify that the StandardTab property is set to false. If this does not help you, could you illustrate the exact scenario? Which is the version of the suite that you are using?

    Kind regards,
    Svett
    the Telerik team
    Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
  5. Alex
    Alex avatar
    3 posts
    Member since:
    May 2011

    Posted 21 Aug 2011 Link to this post

    Thank very much!!!
  6. Alex
    Alex avatar
    3 posts
    Member since:
    May 2011

    Posted 21 Aug 2011 Link to this post

    Thank  very much.
  7. AJing
    AJing avatar
    19 posts
    Member since:
    Jun 2011

    Posted 18 Oct 2011 Link to this post

    HI Avett:

        There is a question  when I removed and added columns of radgridview .
         Details eg::
         1.  I remove columns and save them into Dictionary:

            The dictionary's structure is :Dictionary<int?,GridViewDataColumn> dicColumns=new Dictionary<int?,GridViewDataColumn>();
           
             dicColumns.Add(1,column1);
             dicColumns.Add(2,column2);
             dicColumns.Add(3,column3);
              ...

              radGridView.Columns.Remve("Column1");   //(Column1 is GridViewTextColumn);
              radGridView.Columns.Remve("Column2");    //(Column2 is GridViewImageColumn);
              radGridView.Columns.Remve("Column3");    //(Column3 is GridViewDecimalColumn);
               ...


          2.The I add the columns which in the dictionery dicColumns into grid:
              radGridView.Column.Add(column1);
              radGridView.Column.Add(column2);
              radGridView.Column.Add(column3);
              ...

    The result: some cell loast focus . 
     I am using Telerik controls in Q2 2011 official version after coded using  Q2 2010 demo version

    PS: My english is poor.

       BestRegards!
       Candy

      
  8. Svett
    Admin
    Svett avatar
    728 posts

    Posted 21 Oct 2011 Link to this post

    Hi Ajing,

    I did not manage to reproduce the issue. I am enclosing a sample project which demonstrates my approach. Could you please let me know if I am missing something?

    Greetings,
    Svett
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

  9. AJing
    AJing avatar
    19 posts
    Member since:
    Jun 2011

    Posted 26 Oct 2011 Link to this post

    Hi Svett :

             1.    I just saw your reply today. 
                    We solved the problem. Ours solution is:Before and after removing and adding columns to add: radGridView1.Columns.BeignItemUpdate (); radGridView1.Columns.EndItemUpdate (); 

             eg:  
             radGridView1.Columns.BeignItemUpdate (); 
             radGridView1.Columns.Remove("Column1");   //(Column1 is GridViewTextColumn);
             radGridView1.Columns.EndItemUpdate (); 

            2. We also encountered some other problems
               2.1  With Taiwan's new phonetic input method editors RadGridView, if you need to use the keyboard at this time for the left and right keys to select the desired word, RadGridView the focus will jump to another cell. This result I can not choose the word I need.
    If you use the Winform DataGridView control, then the problem will not occur.
    I do not know RadGridView not need to set some properties can solve this problem?

              2.2 If I use UserDeletingRows events RadGridView multi-row deletion, system error: Value can not null. Paramter name: key. RadControl2011 Q2 I use the official version. But the strange thing is, in our use of previously used 2010Q2Demoversion the same code for the same operation, but no error occurs.
              2.3 I want to use the Expression property of the column automatically calculates the column: Currently our request is this.
    1) a module by setting the calculation of the field relationships. Such as: addition, subtraction, and so on.
    2) to dynamically obtain the RadGridView in the Expression field expression.
    RadGridView in the field is determined, but not necessarily the formula for each field. So now dynamically access and apply it to the Expression property.
    I do not know: 1) access the database directly from the content assigned to the column Expression Expression property to you?
    2) If the divisor is 0, the situation encountered in the system will collapse. Crash phenomenon.

    Greetings
    Look forward to your reply
    Ajing

       
  10. Svett
    Admin
    Svett avatar
    728 posts

    Posted 28 Oct 2011 Link to this post

    Hi Ajing,

    Regarding your questions the answers are:

    1. I am glad to hear that you have resolved the issue on your own.
    2.1 You can suspend the left and right navigation in case of using IME by using the following code snippet:

    public class MyDataRowBehavior : GridDataRowBehavior
    {
        protected override bool ProcessLeftKey(KeyEventArgs keys)
        {
            if (this.EditorManager.IsInEditMode)
            {
                return false;
            }
     
            return base.ProcessLeftKey(keys);
        }
     
        protected override bool ProcessRightKey(KeyEventArgs keys)
        {
            if (this.EditorManager.IsInEditMode)
            {
                return false;
            }
     
            return base.ProcessRightKey(keys);
        }
    }

    BaseGridBehavior gridBehavior = this.radGridView1.GridBehavior as BaseGridBehavior;
    gridBehavior.UnregisterBehavior(typeof(GridViewDataRowInfo));
    gridBehavior.RegisterBehavior(typeof(GridViewDataRowInfo), new MyDataRowBehavior())

    2.2 I did not manage to reproduce the issue with Q2 2011 SP 1 (2011.2 11.831). I have used the following code snippet to reproduce it:
    void radGridView1_UserDeletingRow(object sender, GridViewRowCancelEventArgs e)
    {
        object value = e.Rows[0].Cells[0].Value;
    }

    Did I miss something in my approach?

    2.3.1 You can use the Expression Editor to allow user to define their expressions.

    2.3.2 You can access the bound record that comes from your data source by access the DataBoundItem property of GridViewDataRowInfo class. Nevertheless, If this approach does not suit your requirements, I would like to open a support ticket where you can enclose a sample project which demonstrates your approach.

    2.3.3 At this time the developer should take care of the valid expression. Nevertheless, we will improve handling of invalid expressions and data regarding them in one of the next releases. In the meantime, you should verify that your data source is valid for the expressions that you are using.

    Regards,
    Svett
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

  11. AJing
    AJing avatar
    19 posts
    Member since:
    Jun 2011

    Posted 31 Oct 2011 Link to this post

    Hi Svett:

          Thank you for taking the time to answer my question!
    1.   For the input of the problem, we see your solution is handled this way before:

                    this.radGridView1.GridBehavior = new MyGridBehavior();  
                    public class MyGridBehavior : BaseGridBehavior  
                    {  
                            public override bool ProcessKey(KeyEventArgs keys)  
                            {  
                                    if ( keys.KeyCode == Keys.Left || keys.KeyCode == Keys.Right)  
                                            {  
                                                       return true;  
                                            }  
                                     return base.ProcessKey(keys);  
                               }  
                       }  
                    This resulted in a cell in a non-edit mode, the keyboard can not be used around the key. So we adopted your solution.
    However, if the cell is in edit mode, but no input, then the keyboard can not be used around the key.
                    Is there any way to implement a solution similar to dataGridView control. Use Taiwan New Phonetic IME is functioning?

    2.  How to set the field DefaultFilter to NoFilter?
       We are now to achieve this as fllows:
     eg: FilterDescriptor noFiler=new FilterDescriptor ();
          noFiler.Operator=FilterDescriptor .None;
          radGridView.Columns["Name"].FilterDescriptor =noFiler;     //"Name" is GridViewTextColumn
          radGridView.Columns["Age"].FilterDescriptor =noFiler;          //"Age" is GridViewDecimalColumn
    This will cause some side effects, such as: When I re-query the data, each field of screening have become the same. And the system error.

    3.How to cancel RadRibbonBar in the KeyTip Menu functions? We do not need this feature. Click the Alt key twice because the system will jump to a form, then the form appears confused situation.
    I looked at the KeyTiip Menu is not set, but the control default is 1,2,3. .

     

     

     

    5. I do not understand your question for UserDeletingRow.
    We write their own right-click menu: contextmenustrip to remove it. Call UserDeletingRow the method is not wrong.I do not know how this is going?

    Code is so:

    void radGridView1_UserDeletingRow(object sender, GridViewRowCancelEventArgs e)
    {
      
    List<DataAccess.EmpInfo> lst= new  List<DataAccess.EmpInfo>();
    foreach(var row in radGridView1.SelectedRows)
    {
      DataAccess.EmpInfo info =row.DataBoundItem as DataAccess.EmpInfo;
      lst.Add(info);
    }
    EmpClass.Delete(lst);             //Delete method using Linq to perform

    foreach(var item in lst)
    {
     radgridviewBindingSource.Remove(item) ;  //radgridviewBindingSource is the radGridView1's DataSource
    }

    radgridviewBindingSource.ResetBings(false);  //Refresh

    }


    Greetings
    Look forward to your reply
    Ajing

     

     

     

     

     

  12. Svett
    Admin
    Svett avatar
    728 posts

    Posted 02 Nov 2011 Link to this post

    Hello Ajing,

    The answers of your questions are as follows:

    1. What do you mean by "the keyboard can not be used around the key". I have tried the Microsoft DataGridView and looks that the behavior is the same. Can you give me more information what are your expectation for the behavior in edit mode?

    2. You should create two different filter descriptors for each column. You should use the following code snippet:

    FilterDescriptor nameNoFiler = new FilterDescriptor();
    nameNoFiler.Operator = FilterOperator.None;
    radGridView1.Columns["Name"].FilterDescriptor = nameNoFiler;
     
    FilterDescriptor ageNoFiler = new FilterDescriptor();
    ageNoFiler.Operator = FilterOperator.None;
    radGridView1.Columns["Age"].FilterDescriptor = ageNoFiler; 

    3. You find the answer of your question in this forum post.

    4. I suppose that the issue is caused by forcing the refresh of RadGridView in the UserDeletingRow event. You do not need to do that explicitly, the control does it automatically for you when the row is deleted. Your event handler should look as follows:
    private void radGridView1_UserDeletingRow(object sender, GridViewRowCancelEventArgs e)
    {  
        List<DataAccess.EmpInfo> lst= new  List<DataAccess.EmpInfo>();
         
        foreach(var row in radGridView1.SelectedRows)
        {
           DataAccess.EmpInfo info =row.DataBoundItem as DataAccess.EmpInfo;
           lst.Add(info);
        }
     
        EmpClass.Delete(lst);             //Delete method using Linq to perform
    }

    Regards,
    Svett
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

  13. AJing
    AJing avatar
    19 posts
    Member since:
    Jun 2011

    Posted 02 Nov 2011 Link to this post

    Hi Svett:

          Thank you for your answer.
    1.Your solution about UserDeletingRow envent is useful!

    2. We have solved the alt key issues.

    3. I agree with your point of the sulution about filtering.

    Greetings
    Ajing.
Back to Top
UI for WinForms is Visual Studio 2017 Ready