How to focus control in CellEditTemplate without mouse usage

5 posts, 1 answers
  1. Wirat Chinnan
    Wirat Chinnan avatar
    13 posts
    Member since:
    Aug 2009

    Posted 26 Aug 2009 Link to this post

    When I press "Tab Button" for shifting to the next column that use CellEditTemplate, program will shift and focus on next column correctly but I cannot edit in the cell instantly when cell is focusing. So I must use mouse to click on the cell to make cursor appear and be able to edit data in that column. Is it possible to edit data without using mouse click (just only press tab button) ? If so, How can I do it?

    Thank you in advance.
    Wirat Chinnan
  2. Answer
    Frank
    Frank avatar
    16 posts
    Member since:
    Aug 2012

    Posted 27 Aug 2009 Link to this post

    Hi,

    You can  add the loaded event handler to whatever control is used in the CellEditTemplate.

     

     

     

    <DataTemplate x:Name="CellTemplate_ShortDescription">

     

     

     

    <TextBox x:Name="Text_ShortDescription" Loaded="EditTextBox_Loaded"
    Text="{Binding ShortDescription, Mode=TwoWay}" Height="200" AcceptsReturn="True"

     

     

    VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" TextWrapping="Wrap"

     

     

    BorderBrush="Black" BorderThickness="2" Margin="5"/>

     

     

     

    </DataTemplate>

     

     

     

    In the loaded event  put the code to focus on this control. 
     
     Private Sub  EditTextBox_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)

       Dim textbox = TryCast(sender, TextBox)
        textbox.SelectAll()
       textbox.Focus()

    End Sub

  3. Wirat Chinnan
    Wirat Chinnan avatar
    13 posts
    Member since:
    Aug 2009

    Posted 27 Aug 2009 Link to this post

    Hi Frank



    Thank you very much

    Wirat Chinnan
  4. Dhileep Kumar Sampath
    Dhileep Kumar Sampath avatar
    35 posts
    Member since:
    Oct 2009

    Posted 23 Nov 2009 Link to this post

    Hi All,
        I have a similar requirement but I am adding the texbox to the celledittemplate in the dynamic code and hence i am not able to add the handler "EditTextBox_Loaded". Does anyone have any suggestion for this?

    Thanks,
    Dhileep
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 23 Nov 2009 Link to this post

    Hello,

    You can inherit from desired grid column and add desired control programmatically using CreateCellEditElement similar to this post.

    All the best,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top