Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# find value in datagridview

private void tb_Search_TextChanged(object sender, EventArgs e)
        {


            string searchValue = tb_Search.Text;
            int rowIndex = -1;
            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            try
            {
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    if (row.Cells[0].Value.ToString().Contains(searchValue))
                    {
                        rowIndex = row.Index;
                        dataGridView1.ClearSelection();
                        row.Selected = true;
                        dataGridView1.FirstDisplayedScrollingRowIndex = rowIndex;
                        dataGridView1.Focus();
                        break;
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("No solutions with that name.");
}
}
}
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to write a list to csv c# 
Csharp :: use raycast unity new input system 
Csharp :: c# run batch file 
Csharp :: c# char 
Csharp :: c# datagridview select row right click 
Csharp :: c# round number up 
Csharp :: C# clear console input buffer 
Csharp :: c# get property type of list 
Csharp :: c# even or odd 
Csharp :: how to acivate a game object unity 
Csharp :: checking a gamobjects layer 
Csharp :: c# how to set string list 
Csharp :: how to close a form c# 
Csharp :: what is a model in c# 
Csharp :: how to make a string in c# 
Csharp :: c# read all lines from filestream 
Csharp :: how to make player movement in unity 2d 
Csharp :: Kill System Process in C# 
Csharp :: type or namespace text could not be found unity 
Csharp :: c# funtion 
Csharp :: Map Range Clamped unity 
Csharp :: c# how to call methods from another class 
Csharp :: if statement 
Csharp :: regex for accepting a file name c# 
Csharp :: callling class c# 
Csharp :: Unity rainbow color changing object 
Csharp :: change line color in c# 
Csharp :: how to redirect to another page in button clicked in asp.net c# index.cshtml 
Csharp :: c# for 
Csharp :: onmousedown() not working unity 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =