From: LuvinLunch on
Hi,

I need some advice on how to use a datagridview properly. I'm
converting a vb6 app to vb.net. In the vb6 application I was passing
an empty datagrid by referene to a class I'd written, I was populating
the datagrid and passing it back to the form all set up for action.

I've tried doing the same in vb.net but the class I've written doesn't
recognise the datagridview. So my question is, is passing the
datagridview from a form class to a class I've written the best way to
populate my datagridview? I'm really keen to have the populating of
the grid done in the class and not on the form. Should I be
inheriting the grid into the class? Is the way I'm passing it
incorrect?

All advice gratefully received.

LL
From: Joe Cool on
On Dec 22, 7:18 am, LuvinLunch <martinamul...(a)yahoo.ie> wrote:
> Hi,
>
> I need some advice on how to use a datagridview properly.  I'm
> converting a vb6 app to vb.net.  In the vb6 application I was passing
> an empty datagrid by referene to a class I'd written, I was populating
> the datagrid and passing it back to the form all set up for action.
>
> I've tried doing the same in vb.net but the class I've written doesn't
> recognise the datagridview.  So my question is, is passing the
> datagridview from a form class to a class I've written the best way to
> populate my datagridview?  I'm really keen to have the populating of
> the grid done in the class and not on the form.  Should I be
> inheriting the grid into the class?  Is the way I'm passing it
> incorrect?
>
> All advice gratefully received.
>

I'm not sure but it sounds like the problem is that you don't have an:

Imports System.Windows.Forms

statement in the class.
From: LuvinLunch on
Joe Cool,

You're right. Oh dear, the joys of a new language.

Thanks a million for your help.

LL
From: Gregory A. Beamer on
LuvinLunch <martinamullin(a)yahoo.ie> wrote in news:d21e0201-9edc-47ae-
bef4-d3505872ff20(a)r5g2000yqb.googlegroups.com:

> I've tried doing the same in vb.net but the class I've written doesn't
> recognise the datagridview. So my question is, is passing the
> datagridview from a form class to a class I've written the best way to
> populate my datagridview? I'm really keen to have the populating of
> the grid done in the class and not on the form. Should I be
> inheriting the grid into the class? Is the way I'm passing it
> incorrect?

I am going to counter what "Joe" stated. In a "proper" app, the middle
tier works with data as objects, not as pulled from controls. You are
best to archtiect the solution so the bound data is what you are passing
and not some view from a DataGrid. When you start working with UI
controls, you tightly bind to the UI, making it hard to ever produce
another type of UI for the app without rewriting a huge portion of the
code.

Yes, this may not be an issue for you, but it is something to think
about esp. with the new technology being projectile vomited out at a
high pace.

Peace and Grace,

--
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
From: Cor Ligthert[MVP] on
The datagridview (but that not alone) has a datasource, that is the way you
handle it after VB6.
Simply pass the content of the datasource (always an Ilist implementing
type, but much more variations than the recordset)

The only trouble can be as it is a anonymous class, but even that you can
first convert tolist.

Cor

"LuvinLunch" <martinamullin(a)yahoo.ie> wrote in message
news:d21e0201-9edc-47ae-bef4-d3505872ff20(a)r5g2000yqb.googlegroups.com...
> Hi,
>
> I need some advice on how to use a datagridview properly. I'm
> converting a vb6 app to vb.net. In the vb6 application I was passing
> an empty datagrid by referene to a class I'd written, I was populating
> the datagrid and passing it back to the form all set up for action.
>
> I've tried doing the same in vb.net but the class I've written doesn't
> recognise the datagridview. So my question is, is passing the
> datagridview from a form class to a class I've written the best way to
> populate my datagridview? I'm really keen to have the populating of
> the grid done in the class and not on the form. Should I be
> inheriting the grid into the class? Is the way I'm passing it
> incorrect?
>
> All advice gratefully received.
>
> LL

 |  Next  |  Last
Pages: 1 2
Prev: vb.net
Next: Windows 7 TaskBar API Questions