Display data on DBGrid without needing Data Control? 
Author Message
 Display data on DBGrid without needing Data Control?

Is there any way of using a DBGrid control without assigning to a Data
Control?
In other words I would like to use pure code instead of a control.  Is this
possible and could someone show me any examples.

Thanks
Paul



Sat, 01 Jan 2005 21:47:23 GMT  
 Display data on DBGrid without needing Data Control?
There is indeed, but you've got a bit of trial and error ahead of you :-)

I'll probably be corrected on this, but the only way I can think of is using
data-aware classes. Unfortunately, these things are *abysmally* documented!
But you're lucky - there's a good example in the MSDN Library on using these
with a DataGrid control.

To learn about data-aware classes, follow this route through the Contents
part of the help file:

Visual Basic Documentation --> Using Visual Basic --> Programmer's Guide -->
Part 2: What Can You Do With Visual Basic? --> Programming with Objects -->
Creating Data-Aware Classes.

That provides a fair introduction, but when it comes to the complex-bound
classes you'll need, it falls far short. Find the article entitled "Using
the DataGrid Control with a Class Module". That should do the rest.

You may have noticed that I've said DataGrid control and not DBGrid control.
For some reason, data-aware classes only seem to work with ADO and not DAO,
so if you don't know anything about ADO, you've got a bit of reading ahead
of you. The DBGrid control isn't so happy with ADO, so you'll probably have
to use the DataGrid control instead.

Good luck!

 - Chris Paterson


Quote:
> Is there any way of using a DBGrid control without assigning to a Data
> Control?
> In other words I would like to use pure code instead of a control.  Is
this
> possible and could someone show me any examples.

> Thanks
> Paul



Sat, 01 Jan 2005 22:39:01 GMT  
 Display data on DBGrid without needing Data Control?
I had this same problem while writing some database software. The easiest
and fastest way I could find to do it was to simply use the ADODB Data
Control. I tried to set it up to work without it, but I wasted a few hours
of work and never got it to work.  If you simply don't want the user poking
the ADODB data control, simply make it invisible.

Whitt Batcheler

Quote:
> Is there any way of using a DBGrid control without assigning to a Data
> Control?
> In other words I would like to use pure code instead of a control.  Is
this
> possible and could someone show me any examples.

> Thanks
> Paul



Sat, 01 Jan 2005 23:27:59 GMT  
 Display data on DBGrid without needing Data Control?

Quote:

> Is there any way of using a DBGrid control without assigning to a Data
> Control?
> In other words I would like to use pure code instead of a control.  Is this
> possible and could someone show me any examples.

sample code?  You can 'generate' some yourself using the data form wizard.

If you don't mind using a DataGrid and ADO code, anyway.

From the Project menu, choose "Add Form"
From that dialog, choose the VB Data Form Wizard
Select your database
Choose Form Layout "Grid" and Binding type "ADO Code" when you see those choices

        Bob
--
VB expert looking for work  <http://resumes.dice.com/bobobob>



Sun, 02 Jan 2005 00:31:54 GMT  
 Display data on DBGrid without needing Data Control?
Thanks for the help guys but I think i'll stick with using a DBGrid and Data
Control.
Sensible when you consider i've still got a hell of a lot of work to do in a
very short space of time!

Paul


Quote:
> Is there any way of using a DBGrid control without assigning to a Data
> Control?
> In other words I would like to use pure code instead of a control.  Is
this
> possible and could someone show me any examples.

> Thanks
> Paul



Sun, 02 Jan 2005 02:46:09 GMT  
 Display data on DBGrid without needing Data Control?
You can also bind the DataGrid directly to an ADO recordset:

0. Add a DataGrid to a form but don't change any properties,
especially
   column-related properties. Stuff like Top and Width are safe to
change.
1. Dim the recordset object at form-level.
2. Open the recordset and disconnect it (see the ADO help file if you
don't
   know how).
3. Tell the grid to display the recordset by setting its DataSource to
be the
   recordset (eg. Set DataGrid1.DataSource = m_rstGrid).

It does a fairly good job. See which things you want to change about
the display and add the code for that after the above. If you change
column- or display related properties at design time it will assume
you are taking over and will do practically nothing. Unless you really
want to set absolutely everything manually leave these properties
alone until run time.



Sun, 02 Jan 2005 05:01:19 GMT  
 Display data on DBGrid without needing Data Control?
If you use data binding you will see a terrible performance hit as the
database grows.  I have learned this the hard way.  If speed is your concern
then you need to populate a recorset object and fill in the grid manually.
Trust me this is much faster.

Joe


Quote:
> Thanks for the help guys but I think i'll stick with using a DBGrid and
Data
> Control.
> Sensible when you consider i've still got a hell of a lot of work to do in
a
> very short space of time!

> Paul



> > Is there any way of using a DBGrid control without assigning to a Data
> > Control?
> > In other words I would like to use pure code instead of a control.  Is
> this
> > possible and could someone show me any examples.

> > Thanks
> > Paul



Sun, 02 Jan 2005 05:33:28 GMT  
 Display data on DBGrid without needing Data Control?
That's interesting, Joe. Any idea why that's so?

 - Chris Paterson


Quote:
> If you use data binding you will see a terrible performance hit as the
> database grows.  I have learned this the hard way.  If speed is your
concern
> then you need to populate a recorset object and fill in the grid manually.
> Trust me this is much faster.

> Joe



> > Thanks for the help guys but I think i'll stick with using a DBGrid and
> Data
> > Control.
> > Sensible when you consider i've still got a hell of a lot of work to do
in
> a
> > very short space of time!

> > Paul



> > > Is there any way of using a DBGrid control without assigning to a Data
> > > Control?
> > > In other words I would like to use pure code instead of a control.  Is
> > this
> > > possible and could someone show me any examples.

> > > Thanks
> > > Paul



Sun, 02 Jan 2005 09:21:54 GMT  
 Display data on DBGrid without needing Data Control?
We use the MSFlexGrid instead of the DBGrid for certain items.  The
FlexGrid does not need to be databound.  So you can populate it with
data items, or with anything else that you want.  You can also color
the background of rows, columns, etc.


Tue, 04 Jan 2005 02:14:36 GMT  
 Display data on DBGrid without needing Data Control?
Steve - Is there an elegant way to print the contents of either grid object?
I posted this question elsewhere but it must either be impossible to do or
to explain.
Thanks, Chris

Quote:
> We use the MSFlexGrid instead of the DBGrid for certain items.  The
> FlexGrid does not need to be databound.  So you can populate it with
> data items, or with anything else that you want.  You can also color
> the background of rows, columns, etc.



Wed, 05 Jan 2005 04:48:44 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Display data on DBGrid without needing Data Control?

2. Display data on DBGrid without needing Data Control?

3. Help: DBGrid - Adding data without Data Control?

4. Help: DBGrid - Adding data without Data Control?

5. Data-bound Masked Edit makes all data-bound controls not display data

6. DBGrid without Data Control

7. DBGrid without Data Control

8. DBGrid without a Data Control

9. Can I use dbgrid without data control ?

10. Filling DBGrid without Data Control?

11. DBGrid without Data Control

12. DBGrid without a Data Control

 

 
Powered by phpBB® Forum Software