Focus on Specific Textbox in Listbox

Posted on 2010-01-12
Medium Priority
Last Modified: 2013-11-12
I have a Textbox control inside a listbox under  DataTemplate where I am adding dynamically.
I am checking in the collection whether TextBox is empty or not, if Empty then I am displaying message.
But I want to set the focus to that control  where the textbox is empty.

Question by:sureshchsahu
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Assisted Solution

feddas earned 2000 total points
ID: 26319737
inside the code where you display the message add in code to set the focus to the textbox.

assuming an event is triggered for the textbox when the text box is to get focus you'd use add this line of code inside the if statement displaying the message:
//if textbox is empty do this:
  //... code to display your message
  (TextBox)sender.IsTabStop = True;

Open in new window


Accepted Solution

sureshchsahu earned 0 total points
ID: 26320529
I have found the solution

below will be the code
 TextBox txt = sender as TextBox;
            Collection client= txt.DataContext as Collection;
            if (string.IsNullOrEmpty(client.Code))

Author Comment

ID: 26320540
Got the solution

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question