0

I have a Window in which I bind my DataGrid source to a DataTable with a tree-like structure. In the window, I have a TextBox, and two buttons ("Contains", and "Exact"). And the following is a sample data (in text), along with the Table image:

Comedy
  English
    21 Jump Street
      C Tatum
      J Hill
    22 Jump Street
      C Tatum
      J Hill
    Dumb and Dumber
      J Carrey
      J Daniels
Action
  English
    Mission Impossible 5
      T Cruise
      J Renner
  Hindi
    Singham
      A Devgn
      K Agarwal

http://oi58.tinypic.com/301mtko.jpg

I have a few things I would like to do:

Using the text entered and depending on the button clicked, I'd like to filter my last column (lead actor) of my GridView (just update grid view, not saving to the DataTable). So for example, typing "tum" and clicking 'exact' would do a similar search as it is done for DataTable using DataView, in this case, returning nothing. When 'contains' button is clicked, it should return (GridView table):

Comedy
  English
    21 Jump Street
      C Tatum
    22 Jump Street
      C Tatum

And a 'contains' search for "ar" should return (on the GridView table):

Action
  Hindi
    Singham
      K Agarwal

I have read here and there that I should use BindingSource (https://stackoverflow.com/a/21845837/5003918), but I am not sure exactly how to use it (and return the hierarchy instead of just matching rows). My actual data will probably have unique last columns (unless contains search is used).

Lastly, I have an "export" button which I would like to use to export the current GridView into a CSV.

  • To summarize what I need help with:
    1. "Contains" search from GridView
    2. "Exact" search from GridView (BindingSource?)
    3. Export GridView data (Exporting datagridview to csv file ; Getting an error atm)

I hope, I have (accurately) provided enough information to obtain help. :)

Community
  • 1
  • 1
Mohammad Ali
  • 353
  • 1
  • 6
  • 18
  • I decided to change my table view to a normal row table, so I do not need the hierarchy view. However, I could use some help on the partial search. – Mohammad Ali Jun 19 '15 at 17:00
  • I solved it: I parsed the DataTable and checked if input string was contained in column's text, and if was, write the entire row to another table. At the end, I changed the source of the grid to the new table. – Mohammad Ali Jun 20 '15 at 15:53

0 Answers0