Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6177535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:17:34+00:00 2026-05-24T00:17:34+00:00

I’ve got a datagrid containing part objects, consisting of a handful of template columns.

  • 0

I’ve got a datagrid containing “part” objects, consisting of a handful of template columns. The majority of the fields are read-only, a few of them are editable. The tab key needs to cycle between the editable fields; I seem to have that part worked out. The catch is this… when the user enters a part number into the first textbox, he or she can press TAB or ENTER to lookup the part number and receive a message saying the number is invalid in case of failure, or have that part’s information added to the grid in case of success.

Here is my problem- if they use TAB, the ‘quantity’ textbox needs to become focused, while a new, empty row is added below. If they use the ENTER key, an empty row needs to be added and the new ‘part number’ textbox needs to be focused. I am unable to find a way to focus the textboxes in my viewmodel. I can do it using some events in codebehind, but I can’t find a way to add an unfocused row with TAB, and a focused row with ENTER. Setting CanUserAddRows to true doesn’t even seem to function properly, to this point I’ve been manually adding rows on successful part lookup, which is also causing issues. How can I handle the slightly different tab/enter cases? I potentially also need to able to address lostFocus on the part number box, in case they click another control after entering the number.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:17:34+00:00Added an answer on May 24, 2026 at 12:17 am

    Setting focus should be done in the code-behind of the View, not the ViewModel, because a concept like focus is view-specific

    Adding a new row with the Tab key should be done in the ViewModel. I would register a command on your KeyDown event that goes to your ViewModel and passes it the key that was pressed. The ViewModel would check that the key was the Tab key, and if so add a new row.

    I like using this code from this site for attaching Commands to Events, but there are many other implementations of this functionality around so use whatever you’re comfortable with.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.