Filter gridview data with a textbox and activate directory

0
private void loadGrid()
    {

        DirectoryEntry direntry = new DirectoryEntry();
        direntry.Path = "LDAP://";
        DirectorySearcher dirSearcher = new DirectorySearcher(direntry);
        dirSearcher.PropertiesToLoad.Add("givenName");
        dirSearcher.PropertiesToLoad.Add("sn");
        dirSearcher.PropertiesToLoad.Add("title");
        dirSearcher.PropertiesToLoad.Add("employeeNumber");
        dirSearcher.Filter = "(objectClass=User)";


        dataGridView1.Columns.Add("givenName", "Nombre");
        dataGridView1.Columns.Add("sn", "Apellido");
        dataGridView1.Columns.Add("title", "Puesto");
        dataGridView1.Columns.Add("employeeNumber", "# Empleado");
        dataGridView1.Columns.Add("sAMAccountname", "Username");
        int row = 0;

        foreach (SearchResult sr in dirSearcher.FindAll())
        {
            dataGridView1.Rows.Add(sr.GetDirectoryEntry().Properties["givenName"][0]);
            dataGridView1.Rows[row].Cells[1].Value = (sr.GetDirectoryEntry().Properties["sn"]).Value;
            dataGridView1.Rows[row].Cells[2].Value = (sr.GetDirectoryEntry().Properties["title"]).Value;
            dataGridView1.Rows[row].Cells[3].Value = (sr.GetDirectoryEntry().Properties["employeeNumber"]).Value;
            dataGridView1.Rows[row].Cells[4].Value = (sr.GetDirectoryEntry().Properties["sAMAccountname"]).Value;
            row++;
        }
    }

The above code works to load the data of an active directory path in a datagridview, when clicking on a button (that we put for test purposes) the ALL values are loaded in that route. My question is, how do I make a textbox as I go typing a name I go showing the values in the datagrid, that is if I write "Pablo" show me all the pablo, that if I write "pereira" all those who wear pereira (and that the filter works even if you do not put accents)

    
asked by sullivan96 05.02.2018 в 22:29
source

0 answers