473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how to focus the text in the textbox

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
2 1241
zmbd
5,501 Expert Mod 4TB
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
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

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

Similar topics

4
by: Albinas | last post by:
Hi all, I am trying to customize the text box to suit the practice of my app. And I am working about the focus behavior of text field. I have met the the following problem. When I set the...
4
by: Saifee | last post by:
Hello, How do i set focus on text box or any web control in my aspx.vb page..pls help
1
by: Gill Smith | last post by:
when the page is loaded I am using onload event at the client side and setting the focus on the control(TextBox). However when the user clicks on Clear ImageButton, I am clearing all the text boxes...
4
by: JC | last post by:
Hello- I have a form which has a listbox, a textbox and a submit button. The user types a phone number into the textbox, clicks button, text gets added to the listbox. After this process I need...
5
by: Tosch | last post by:
I have a usercontrol with a label, a textbox, a treeview, a grid and a couple of checkboxes. The usercontrol is hosted on a form together with a cancel and a accept button. This form is used to...
3
by: Joey | last post by:
I have a javascript piece that sets focus to a textbox on one of my webforms. The script works fine for IE: it sets the cursor blinking in the textbox. In Firefox, however, it doesn't work at all....
3
by: muskan | last post by:
hello I want to set the focus in textbox control. I have tried a lot but it is not woking.Tell any property or method for this but without setting the tabindex property. so how it will be...
33
by: me2tech | last post by:
Hi, This is ram. I am developing a page(usereg.jsp) with two textboxes one for username and another for email. Since i am using this page in main.jsp using Ajax, I am removing the body part in...
3
by: nityaprashant | last post by:
how to set focus on textbox inside panel(asp panel) inside ajax update panel plz help me..it's urgent...
2
by: zahid313 | last post by:
Hi all i am trying to set focus in textbox. Its a System.Web.UI page. and textbox is System.Web.UI.WebControls so using setfocus works fine in desktop window but setfocus doesnt work in windows...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.