This is a migrated thread and some comments may be shown as answers.

How to focus control in CellEditTemplate without mouse usage

4 Answers 117 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Wirat Chinnan
Top achievements
Rank 1
Wirat Chinnan asked on 26 Aug 2009, 05:54 PM
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

4 Answers, 1 is accepted

Sort by
0
Accepted
Frank
Top achievements
Rank 1
answered on 27 Aug 2009, 03:57 PM

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

0
Wirat Chinnan
Top achievements
Rank 1
answered on 27 Aug 2009, 05:12 PM
Hi Frank



Thank you very much

Wirat Chinnan
0
Dhileep Kumar Sampath
Top achievements
Rank 1
answered on 23 Nov 2009, 07:44 AM
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
0
Vlad
Telerik team
answered on 23 Nov 2009, 07:59 AM
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.
Tags
GridView
Asked by
Wirat Chinnan
Top achievements
Rank 1
Answers by
Frank
Top achievements
Rank 1
Wirat Chinnan
Top achievements
Rank 1
Dhileep Kumar Sampath
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or