Note that there are some explanatory texts on larger screens.

plurals
  1. POc# Generic list filter
    primarykey
    data
    text
    <p>I have a list of objects. My classes looks like this:</p> <pre><code> class Line { public string A { get; set; } public object B { get; set; } public string C { get; set; } } class More_B { public Information Information { get { return _Information; }} public Description Description { get { return _Description ; }} private Information _Information = new Information(); private Description _Description = new Description (); } class Information { public string Name { get; set;} public string Type { get; set;} public string Further_Info { get; set;} } </code></pre> <p>In my main class at the end I get all data inside <code>Line</code> class like this.</p> <pre><code>More_B info = new More_B(); Line main = new Line(); main.A = "Information about device"; main.B = info; main.C = "Some more information could be display here"; list3.Add(main); </code></pre> <p>So at the end I get list inside which I have all 3 fields <code>A</code> <code>B</code> <code>C</code>. I have my string values in <code>A</code> and <code>C</code> and in <code>B</code> when I check in debug mode I have Information object and inside of it I have all fields like <code>Name</code> <code>Type</code> and <code>Further_Info</code>.</p> <p>I later want to filter this column based on these values "Name" "Type" and "Further_Info", I tried it this way but it is not working. (I binded my list to DataView to be able to use RowFilter).</p> <pre><code>view2.RowFilter = "Line like '%" + textBox2.Text + "%'"; </code></pre> <p>How can I do it right?</p> <p>I am new to C#, so please forgive me, if I did something wrong. If something is hard to understand, let me know and I will try to post more of my code explaining what I did.</p> <p>EDIT: When I use this statement <code>view2.RowFilter = "Line like '%" + textBox2.Text + "%'";</code> I get error <code>Cannot perform 'Like' operation on read_display.More_B and System.String.</code></p> <p>EDIT2: I have 2 more methods for creating datatable for my class and then I do it like this: <code>DataTable ListAsDataTable2 = BuildDataTable2&lt;Line&gt;(list3); DataView ListAsDataView2 = ListAsDataTable2.DefaultView; this.dataGridView4.DataSource = view2 = ListAsDataView2;</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload