TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Albert
NA
42
4.3k
How to focus on cell by typing charachters in datagridview
Jul 7 2017 7:07 AM
I want to focus on cell which contains pressed characters.
Assume datagridview which contains two column Name and Address.
Now in Name column there is lot of records Like Nims, john, kan, rocks, rita, etc...
Now if I am entering character 'K','A','N' then cell will be focus on kan.
I have google for this but I get solution as below code which didn't satisfied my question.
Because it is focus cell which contains pressed character as starting character of cell value.
Thanks in advance.
Code I have tried
private void dataGridView1_KeyPress(object sender, KeyPressEventArgs e)
{
if (Char.IsLetter(e.KeyChar))
{
for (int i = 0; i < (dataGridView1.Rows.Count); i++)
{
if (dataGridView1.Rows[i].Cells["Name"].Value.ToString().StartsWith(e.KeyChar.ToString(), true, CultureInfo.InvariantCulture))
{
dataGridView1.Rows[i].Cells[0].Selected = true;
return; // stop looping
}
}
}
}
Reply
Answers (
1
)
Validation of a formula
How To Make resolution independent windows form c#