Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 699
  • Last Modified:

ListView Press Enter to move to next subitem

I have created a ListView, with all the subitem enable user to key in data. The textbox name is EditBox.

And I want it to be when user press enter key, it will move the cursor to next subitem, and when reach the last subitem and user press enter, it will move cursor to the next first subitem.

For example as below:
Location      temperature    pH      total iron    hazen
A1
A2
A3
A4
A5
A6.....All together 50 rows

The location cannot keyin. And the field for temperature, pH, total iron and hazen can be key in by user. When user key in temperature for A1, and press enter, it will move focus to pH for A1. When user key in hazen for A1, and press enter, it will move focus to temperature for A2.

Can anybody help me on this. Expert, please help me.
0
alicealiciasarawak
Asked:
alicealiciasarawak
  • 8
  • 2
  • 2
  • +1
1 Solution
 
psalkiewCommented:
Create a keypress event on listview object.

Check if the key pressed was an enter button - and increment selectedindex property. Check if it reaches the end of the list and in that case reset the selectedindex to 0.

0
 
Meir RivkinFull stack Software EngineerCommented:
C# / vb.net?
0
 
Meir RivkinFull stack Software EngineerCommented:
how did you implement editable listview?
since it is not built in functionality in .net listview, you probably customized your control.
if you used floating editbox controls (like in this post http://www.csharphelp.com/2006/10/c-editable-listview/)
then you already have a keypress event handler of the editbox control.
so all u need is to check subItemSelected id.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
alicealiciasarawakAuthor Commented:
I have develop the ListView using VB.NET. And I have tried the keypress for listview and also the textbox. It is not working. I really need expert help.
0
 
alicealiciasarawakAuthor Commented:
Can anyone help me on this. I just want it to move to next subitem when I press enter key. Can provide sample code for this please.
0
 
alicealiciasarawakAuthor Commented:
I have used the sample from this link. http://www.codeguru.com/vb/gen/vb_forms/listviewcontrols/article.php/c16251. Now I want that when I press enter it will move the cursor to next subitem.

Expert, please help for this.
0
 
alicealiciasarawakAuthor Commented:
Hello,

Can anyone reply me? sedgwick, the example you gave me I don't want it be like that. I want it to be when user edit the field City and press enter, it will automatically move cursor or focus to second City field and do editing and press enter, it will move cursor to Continent and do editing, and press enter, it will move focus to next line.
0
 
alicealiciasarawakAuthor Commented:
psalkiew,

Can I have a sample for this? I have the listview with textboxes using the sample from http://www.codeguru.com/vb/gen/vb_forms/listviewcontrols/article.php/c16251.

Please do help me on this.
0
 
alicealiciasarawakAuthor Commented:
Can anyone help me?
0
 
Deepak LakkadCommented:
Hi,

In ListView, Selected SubItem can be identified by X and Y co-ordinates i.e. Location where Mouse is clicked.

Location cannot be identified with KeyPress Events...

So, it is difficult to find selected Item when particular Key is pressed ...

That's why, I think so, you cannot move to next SubItem when user presses Enter Key.


- Deepak Lakkad
0
 
alicealiciasarawakAuthor Commented:
deepaklakkad,

So it is not convenient to use ListView, right? For DataGridView, can you give me a sample code for this? I really need your help.
0
 
Deepak LakkadCommented:
Hi

I have attached a file here.

It contains a custom control with a Test Class.

may be this will solve your requirements

- Deepak Lakkad
MyDGV.zip
0
 
alicealiciasarawakAuthor Commented:
Partially solved
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 8
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now