Click here to Skip to main content
15,913,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi everyone

I want to know if there anyway to to set focus on a particular RAW of a grid view when grid view is too long. i mean as a example if grid view has 250 Rows then eventually asp.net webpage get larger.which means we have to scroll down and found the particular page. But in this case i have provided text box to read bar codes and if the bar code Number is in the grid view it must be highlighted. that highlighting part is OK. but when grid has lot of raws (100 , 200, even 500 also possible) raw is selected but operating persons have to scroll down until it found the selected row.
So what i need is to Focus on that Selected raw (Without Scroll down)

So if anyone Could help me on this matter That would be really great!!!
Thanks in advance!!!
Posted
Updated 29-Nov-12 21:45pm
v2

1 solution

Add a handler to the SelectedIndexChanged event of your GridView and insert the following code into this handler:
GridView1.SelectedRow.Focus();

or try this:
C#
dataGridView1.ClearSelection();
int nRowIndex = dataGridView1.Rows.Count - 1;

dataGridView1.Rows[nRowIndex].Selected = true;
dataGridView1.Rows[nRowIndex].Cells[0].Selected = true;
 
Share this answer
 
Comments
Hesha 30-Nov-12 3:22am    
Thanks buddy ..but it did not work.1st method you mentioned i have tried it before. 2nd one also not worked for me.i have to bit changed the syntex you mentioned above.if there any other way to do it?
[no name] 30-Nov-12 3:24am    
What are you getting ?
Hesha 30-Nov-12 3:27am    
page does not go down and focus on the raw. it is just selecting the raw.but not focus on that.i have to scroll down and see the selected raw. hm.. that would be really hazard when grid has 200 Rows minimum.

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