Click here to Skip to main content
15,440,341 members
Home / Discussions / C#
   

C#

 
GeneralRe: HTML Input Controls Value Pin
OriginalGriff19-Jun-22 21:51
mveOriginalGriff19-Jun-22 21:51 
GeneralRe: HTML Input Controls Value Pin
Dave Kreskowiak20-Jun-22 3:49
mveDave Kreskowiak20-Jun-22 3:49 
GeneralRe: HTML Input Controls Value Pin
Member 1431490220-Jun-22 3:56
MemberMember 1431490220-Jun-22 3:56 
GeneralRe: HTML Input Controls Value Pin
Dave Kreskowiak20-Jun-22 3:57
mveDave Kreskowiak20-Jun-22 3:57 
GeneralRe: HTML Input Controls Value Pin
Member 1431490220-Jun-22 3:58
MemberMember 1431490220-Jun-22 3:58 
GeneralRe: HTML Input Controls Value Pin
Dave Kreskowiak20-Jun-22 4:00
mveDave Kreskowiak20-Jun-22 4:00 
GeneralRe: HTML Input Controls Value Pin
Mycroft Holmes20-Jun-22 12:31
professionalMycroft Holmes20-Jun-22 12:31 
QuestionHow filter a DataGridView filled from csv file... Pin
grennday11-Jun-22 21:06
Membergrennday11-Jun-22 21:06 
Hello,
I filled up a DataGridView from a csv file using the code as follow:

Everything works and at the start I can see my DataGridView correctly filled up by datas from csv file.
The problem is that I am not able to filter the rows by textbox or sort the column by clicking on header word.
I tried differents ways by reading solution on the web but nothings works...
can anyone suggest me some solution for this pls?


C#
    private void LoadDatabaseBtn_Click(object sender, EventArgs e)
    {
        string filecsv = @"D:\Database.csv";
        DGV.DataSource = LoadCSV(filecsv);
        DGV.Refresh();
    }
    public List<Client> LoadCSV(string csvfile)
    {
       var query = from l in File.ReadAllLines(csvfile)
                    let data = l.Split(',')
                    select new Client
                    {
                        name= data[0],
                        id = data[1],
                        tel = data[2],
                        addr = data[3],
                        city = data[4],
                    };
        return query.ToList();
    }
}
public class Client
{
    public string name { get; set; }
    public string id { get; set; }
    public string tel { get; set; }
    public string addr { get; set; }
    public string city { get; set; }
}



I have an identical database .mdf, in this case I added a DataSets to my c# project and I fill up my DataGridView just by setting the ClientsTableBindingSouce as source of data
In this case I am able to sort and filter very easly the rows of the datagridview at runtime just by typing text in a textbox.

C#
private void filternameTxt_TextChanged(object sender, EventArgs e)
        {
            ClientsTableBindingSource.Filter = string.Format("name LIKE '%{0}%'", filternameTxt_Text);
            DGV.Refresh();
        }

AnswerRe: How filter a DataGridView filled from csv file... Pin
Richard MacCutchan11-Jun-22 21:18
mveRichard MacCutchan11-Jun-22 21:18 
GeneralRe: How filter a DataGridView filled from csv file... Pin
grennday15-Jun-22 19:40
Membergrennday15-Jun-22 19:40 
GeneralRe: How filter a DataGridView filled from csv file... Pin
Richard MacCutchan15-Jun-22 22:03
mveRichard MacCutchan15-Jun-22 22:03 
GeneralRe: How filter a DataGridView filled from csv file... Pin
grennday16-Jun-22 20:15
Membergrennday16-Jun-22 20:15 
GeneralRe: How filter a DataGridView filled from csv file... Pin
Richard MacCutchan16-Jun-22 20:55
mveRichard MacCutchan16-Jun-22 20:55 
GeneralRe: How filter a DataGridView filled from csv file... Pin
grennday17-Jun-22 19:47
Membergrennday17-Jun-22 19:47 
GeneralRe: How filter a DataGridView filled from csv file... Pin
Richard MacCutchan17-Jun-22 21:59
mveRichard MacCutchan17-Jun-22 21:59 
GeneralRe: How filter a DataGridView filled from csv file... Pin
Eddy Vluggen18-Jun-22 11:11
professionalEddy Vluggen18-Jun-22 11:11 
GeneralRe: How filter a DataGridView filled from csv file... Pin
grennday18-Jun-22 20:55
Membergrennday18-Jun-22 20:55 
GeneralRe: How filter a DataGridView filled from csv file... Pin
grennday24-Jun-22 21:14
Membergrennday24-Jun-22 21:14 
QuestionIVideoWindow.SetWindowPosition not working Pin
Le@rner8-Jun-22 21:18
MemberLe@rner8-Jun-22 21:18 
AnswerRe: IVideoWindow.SetWindowPosition not working Pin
OriginalGriff8-Jun-22 21:53
mveOriginalGriff8-Jun-22 21:53 
QuestionLists C# Pin
Rui Couto6-Jun-22 3:23
MemberRui Couto6-Jun-22 3:23 
AnswerRe: Lists C# Pin
OriginalGriff6-Jun-22 3:54
mveOriginalGriff6-Jun-22 3:54 
GeneralRe: Lists C# Pin
Rui Couto6-Jun-22 5:16
MemberRui Couto6-Jun-22 5:16 
GeneralRe: Lists C# Pin
OriginalGriff6-Jun-22 5:54
mveOriginalGriff6-Jun-22 5:54 
GeneralRe: Lists C# Pin
James Curran21-Jun-22 7:31
MemberJames Curran21-Jun-22 7:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.