i have created a windows application with 5 textboxes using c#

Posted by Sravanthi.seeta under C# on 11/13/2010 | Points: 10 | Views : 1799 | Status : [Member] | Replies : 3
i have created a windows application with 5 textboxes using c#. how to find which textbox is selected among 5 textboxes..




Responses

Posted by: Sravanthi.seeta on: 11/13/2010 [Member] Starter | Points: 25

Up
0
Down
i have created a windows application with 5 textboxes using c#. how to find which textbox is selected among 5 textboxes..

Sravanthi.seeta, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.saravanan on: 11/15/2010 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Its a small difficult to find out which textbox user will be selected.

If you using any button event means following this way...

Step 1: Set one TextBox Enter event into all TextBox Control (For ex: textbox1_Enter to call the same event to all TextBox Control)
Step 2: In your Enter event to find out the TextBox name using the following code
TextBox txtName = (TextBox)sender;

string sName = txtName.Name;

Step 3: Now in your Button Event to get the String name(Note: sName declare in global) to check the condition easily to find out which textbox user selected last.

else
just use TextBox enter event to find out which textbox selected.

Try this way you can achieve your output.

Cheers :)


Thanks,
T.Saravanan

Sravanthi.seeta, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 11/15/2010 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
A textbox is not like a list box or other controls related to that. Are you looking mybe for the "GotFocus" event, if so look at this

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.gotfocus.aspx

Thank you for Posting at DotnetFunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Sravanthi.seeta, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response