I want to search by filter this Data Grid View I have searched so many time for a way to do that but nun of the solutions I found worked with my code ( this is the code I use to load the data grid view )
static public string APP_FOLDER = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Tools/Admin Tool/");
public string fileItem = ("Item.txt");
public class itemInterface
{
public string Code { get; set; }
public string Item { get; set; }
public itemInterface(string key, string value)
{
Code = key;
Item = value;
}
public itemInterface(string[] value)
{
Code = value[0];
Item = value[1];
}
}
static public void UpdateItemDataGridView(DataGridView dgv, List<itemInterface> pList)
{
dgv.ColumnHeadersVisible = false;
dgv.DataSource = pList;
dgv.Columns[0].Width = 70;
dgv.ColumnHeadersVisible = true;
}
private void Form1_Load(object sender, EventArgs e)
{
List<itemInterface> pList = new List<itemInterface>();
using (StreamReader sr = new StreamReader(APP_FOLDER + fileItem, Encoding.UTF8, true))
{
string s = String.Empty;
while ((s = sr.ReadLine()) != null)
{
itemInterface l = new itemInterface(s.Split('\t'));
pList.Add(l);
}
}
UpdateItemDataGridView(dataGridView2, pList);
}