Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello friend please help me


i have datagridview in my project like

PARTYNAME C/D AMOUNT NARRATION <-(MY datagridview COLUMN name)
JOHN c 250 xyz
JONY d 300 xyz
MONY c 500 xyz
SMITh d 230 xyz
DEvlin c 150 xyz
methu d 150 xyz


i have combo box with holds all party name and visible true wherever user press enter key on column if he want to change party name


my problem is that whenever i enter let if i want to change name john i set cursor on john (cell) and i press enter key cursor move jony(min next row)so i want to stop untill cursor on last cell the row this thing (stop cursor to move next row) can any buddy help me

thnaks in advanced

ROSY
Posted

1 solution

If I understand your question, you want to prevent the cursor going down to the next row when a user presses Enter, unless the cursor is on the last row. Let me know if I understand that.

Also what do you want to happen when the Enter key is pressed? Do you want it to stay where it is, do you want it to move over to the next cell in the same row, or do you want a CR to be inserted into the cell where the cursor is at, or something else?

My quick answer about this would be to watch the keys being pressed when the DataGrid has focus, and set the Handled property in the event argument to true when you don't want the cursor moving, and leave it as is when you do want it to go to the next cell. The event handler could read properties from the DataGrid to determine if the cursor was in the last row. You would need to compare the index of the active row with the count of rows in the DataGrid to make that desalinization.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900