herbkanis 0 Newbie Poster

Hi everyone,
I'm trying to understand how things work, more than simply solving a task.
So before I post any code, here is an overview of the question. Maybe someone has some thoughts as to the ways to accomplish this.

I understand the basics of a datagridview and it works just fine, but I would like to know the best way to do it if the project were to become very large. I'm trying to keep as much of the code out of the FORM so I can reuse the code on many forms in the future.

FORM1
|
Load Form
Create empty dataGridview
Add DataTable to it
|
Press a load button
| ------------> ButtonHandler class
|
Fills FORM1 with 20+ buttons, events,properties (from sql)
|
Press one of 20+ buttons
|
| ------------> ButtonHandler class
|
Detect button Pressed, fetch data about some item
|
<----------------- Return data to FORM1
|
Save in FORM1 variables or object or class
|

At this point I'm doing something wrong.
I can see the variables in FORM1 hold the correct values. If I load them with a button from FORM1, the datatable populates and adds rows. Everything is fine, but I don't want the user to have to press a button to populate the grid.

When I try to load them directly into the dataTable from the ButtonHandler, it says there are no columns.

More than anything, I would like to understand how the objects are related and why the buttonclass code can't "see" the grid and datatable in FORM1

Thanks in advance