By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,825 Members | 1,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,825 IT Pros & Developers. It's quick & easy.

Using DataGridView with Hashtables

P: n/a
Hello everybody!

I'm using C# to program a library management tool and am done with the
storage of the data in an xml-structure. The data are read at startup and
managed in a hash table for fast searching, since the amount of book-objects
goes into the 10k's.

I'm working around the display of the data with a DataGridView. Could
someone explain to me, how to transfer the data into the structure, since i
can use an object as a data source. I tried creating a table class, using a
struct row containing the fields and instantiate new rows by using a "query"
on the hashtables. But now i have no idea, how to display these rows in the
grid.

Any help would be MUCH appreciated ...

Robert
Sep 8 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Robert,

it would be better if you use DataTable and DataSets that can be
directly bound to a grid.

See the following links :

http://msdn2.microsoft.com/en-us/lib...datatable.aspx
http://msdn2.microsoft.com/en-us/library/fbk67b6z.aspx

(The latter although it applies to data fetched from SQL Server it will
give you an indication on how to bind a datatable to the grid)

Regards,
Tasos

Thrasher wrote:
Hello everybody!

I'm using C# to program a library management tool and am done with the
storage of the data in an xml-structure. The data are read at startup and
managed in a hash table for fast searching, since the amount of book-objects
goes into the 10k's.

I'm working around the display of the data with a DataGridView. Could
someone explain to me, how to transfer the data into the structure, since i
can use an object as a data source. I tried creating a table class, using a
struct row containing the fields and instantiate new rows by using a "query"
on the hashtables. But now i have no idea, how to display these rows in the
grid.

Any help would be MUCH appreciated ...

Robert
Sep 8 '06 #2

P: n/a
Thank you Tasos for your quick reply!

The links surely were useful, now i have a DataTable holding the book
details, for testing i started with just 1 field Title.
And the DataTable is assigned as DataBinding at the form_load to a DataGrid.
But the DataGrid doesn't show the records i inserted, resetBindings and
refresh doesn't help here. Which important feature am i missing out?

btw, considering the amount of data used, would you recommend searching in a
hashTable, accessing the objects directly and writing the changes back to the
dataTable or do it on the table itself?
bc quick filtering options like "show all books from this author", "find
similar titles" etc are required, along with normal search for title, isbn
etc...

Thank you
Robert

"Tasos Vogiatzoglou" wrote:
Robert,

it would be better if you use DataTable and DataSets that can be
directly bound to a grid.

See the following links :

http://msdn2.microsoft.com/en-us/lib...datatable.aspx
http://msdn2.microsoft.com/en-us/library/fbk67b6z.aspx

(The latter although it applies to data fetched from SQL Server it will
give you an indication on how to bind a datatable to the grid)

Regards,
Tasos

Sep 9 '06 #3

P: n/a
You should have a bindingsource which is the datasource of the grid and has a
datasource of your datatable.
you can uise the Filter properties of the datatable to run searchs like sql
where clauses or get a grid like the infragistics grid which has filtering
and searching built in and very good and flexible

Ciaran O'Donnell

"Thrasher" wrote:
Thank you Tasos for your quick reply!

The links surely were useful, now i have a DataTable holding the book
details, for testing i started with just 1 field Title.
And the DataTable is assigned as DataBinding at the form_load to a DataGrid.
But the DataGrid doesn't show the records i inserted, resetBindings and
refresh doesn't help here. Which important feature am i missing out?

btw, considering the amount of data used, would you recommend searching in a
hashTable, accessing the objects directly and writing the changes back to the
dataTable or do it on the table itself?
bc quick filtering options like "show all books from this author", "find
similar titles" etc are required, along with normal search for title, isbn
etc...

Thank you
Robert

"Tasos Vogiatzoglou" wrote:
Robert,

it would be better if you use DataTable and DataSets that can be
directly bound to a grid.

See the following links :

http://msdn2.microsoft.com/en-us/lib...datatable.aspx
http://msdn2.microsoft.com/en-us/library/fbk67b6z.aspx

(The latter although it applies to data fetched from SQL Server it will
give you an indication on how to bind a datatable to the grid)

Regards,
Tasos

Sep 9 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.