c# - Search datagridview on user keypress -


I am trying to select the first row where the value of the cell starts with the single insect pressed by the user is. This is the part that is bothering me.

Here's how I'm handling this incident ( has been updated with work solution ):

  Private zero DataGridView1_KeyPress {Object Sender, KeyPressEventArgs E} {for (Char.IsLetter (e.KeyChar)} {{int i = 0; I & lt; (DataGridView1.Rows.Count); i ++) {if (dataGridView1 Rows [i] ..cells ["name"] Value.ToString () StartsWith (e.KeyChar.ToString (), true, CultureInfo.InvariantCulture) {dataGridView1.Rows [i] .cs [0] .Selected = True return; // stop looping}}}}  

I'm sure this is something that I'm ignoring, but it is not possible for me to know what it is.

Edit

The code was updated with the address applied

Maybe the issue of the case, the value in the cell starts with a capital letter ["name"]? Try using ToUpper or ToLower on both; Or you can try to ignore start with (e.kker, true). If you are trying to select the row, you would want to do DataGrid View1. Rows [i]. Selected = true


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -