By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,824 Members | 2,410 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,824 IT Pros & Developers. It's quick & easy.

how to focus the text in the textbox

P: 6
I have an SlectedIemchanged event in the treeview...
when i select item it should call the got focus function for particular selected item...

thank you
Apr 22 '15 #1
Share this Question
Share on Google+
2 Replies


zmbd
Expert Mod 5K+
P: 5,397
you will need to show your code.
Please format it by selecting your posted script and clicking on the [CODE/] format button in the tool bar.
Apr 22 '15 #2

P: 6
example code:
Expand|Select|Wrap|Line Numbers
  1. private void selected(object sender,  RoutedPropertyChangedEventArgs<object> e)
  2.         {
  3.                 TreeViewItem t;
  4.                 t = (TreeViewItem)tvMain.SelectedItem;
  5.                 MessageBox.Show(t + " ");
  6.                 StackPanel s = (StackPanel)t.Header;
  7.                 List<TextBlock> l = new List<TextBlock>(4);
  8.  
  9.                 foreach (TextBlock children in s.Children)
  10.                 {
  11.                     l.Add(children);
  12.                 }
  13.  
  14.                 string ch = l[3].Text;
  15.                 string[] strarr1 = ch.Split('-');
  16.                 textBox_GotFocus(strarr1[0], strarr1[1]);
  17.  
  18.         }
when i click on the treeview it should enter the textBox_GotFocus function and particular textbox get the focus....
if i click on the child instead of focusing textbox it will go to its parent node
Expand|Select|Wrap|Line Numbers
  1.    private void textBox_GotFocus(string str1,string str2)
  2.         {
  3.             int i=Convert.ToInt16(str1);
  4.             int j=Convert.ToInt16(str2);
  5.             int k = j - i;
  6.             PacketDisplay2.SelectionStart = i * 3;
  7.             PacketDisplay2.SelectionLength = (k + 1) * 2 + k;
  8.             PacketDisplay2.Focus();
  9. }
  10.  
thank you
Apr 22 '15 #3

Post your reply

Sign in to post your reply or Sign up for a free account.