468,283 Members | 1,810 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,283 developers. It's quick & easy.

Using DataGridView with Hashtables

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
3 7450
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
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
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.

Similar topics

13 posts views Thread by Anders Borum | last post: by
1 post views Thread by Curtis | last post: by
4 posts views Thread by gene kelley | last post: by
2 posts views Thread by Steve Richter | last post: by
reply views Thread by jeastman - Hotmail | last post: by
7 posts views Thread by Mike P | last post: by
2 posts views Thread by MrBee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.