Home All Groups Group Topic Archive Search About
Author
11 Jun 2009 11:56 PM
Webbiz
I have a function that calls a method contained in another form that
is not currently loaded.

By calling the form2.method, the form will load.

On this form is a DataGrid.

The form2.method fills this DataGrid from a Recordset that it is
binded to.

Whenever I call this form2.method, you can see the form starting to
show. However, it does not completely show UNTIL the DataGrid has been
fullying loaded with the Recordset data.

This looks hokey.

I've tried placing a DoEvents at various places. Just before the
calling function, just after. I've tried it in the form2.load, the
..activate, and even before the line of code that actually binds the
Recordset to the Datagrid.

None of these measures seem to work.

Can someone suggest how I can get this to either not show the form
until its ready to display the information or to show the form
completely prior to loading the data so that it doesn't 'ghost' while
loading?

No doubt slower computers would really make this stand out. So I'd
like to avoid this behavior altogether.

Thank you in advance.

Webbiz

Author
12 Jun 2009 1:27 AM
MikeD
Show quote Hide quote
"Webbiz" <nospam@forme.thanks.com> wrote in message
news:7363359r35dlmrge1q6bho80u8ue6frtae@4ax.com...
>I have a function that calls a method contained in another form that
> is not currently loaded.
>
> By calling the form2.method, the form will load.
>
> On this form is a DataGrid.
>
> The form2.method fills this DataGrid from a Recordset that it is
> binded to.
>
> Whenever I call this form2.method, you can see the form starting to
> show. However, it does not completely show UNTIL the DataGrid has been
> fullying loaded with the Recordset data.
>
> This looks hokey.
>
> I've tried placing a DoEvents at various places. Just before the
> calling function, just after. I've tried it in the form2.load, the
> .activate, and even before the line of code that actually binds the
> Recordset to the Datagrid.
>
> None of these measures seem to work.
>
> Can someone suggest how I can get this to either not show the form
> until its ready to display the information or to show the form
> completely prior to loading the data so that it doesn't 'ghost' while
> loading?
>
> No doubt slower computers would really make this stand out. So I'd
> like to avoid this behavior altogether.

It all has to do with when you're loading the form, when you're loading the
data into the Datagrid, and when you're showing the form.  You should be
doing all of these things explicitly rather than some of them being done
implicitly (which it sounds like is what you're doing). The other point to
keep in mind is that screen redraws are a very low priority.  In fact, they
only occur when you're app has nothing else to do unless you explicitly code
it. You might re-write your code so that the datagrid doesn't get loaded
until AFTER the form has been shown. Alternatively, load the form, load the
data grid and then don't show the form until the datagrid is completely
loaded.  I'm unsure about some of this because I never use data-binding and
so don't know what, if any, differences that could make.

Might help us to help you if you posted the code for this form2.method you
kept mentioning.

--
Mike
Author
12 Jun 2009 3:48 PM
Webbiz
Show quote Hide quote
On Thu, 11 Jun 2009 21:27:39 -0400, "MikeD" <nob***@nowhere.edu>
wrote:

>
>"Webbiz" <nospam@forme.thanks.com> wrote in message
>news:7363359r35dlmrge1q6bho80u8ue6frtae@4ax.com...
>>I have a function that calls a method contained in another form that
>> is not currently loaded.
>>
>> By calling the form2.method, the form will load.
>>
>> On this form is a DataGrid.
>>
>> The form2.method fills this DataGrid from a Recordset that it is
>> binded to.
>>
>> Whenever I call this form2.method, you can see the form starting to
>> show. However, it does not completely show UNTIL the DataGrid has been
>> fullying loaded with the Recordset data.
>>
>> This looks hokey.
>>
>> I've tried placing a DoEvents at various places. Just before the
>> calling function, just after. I've tried it in the form2.load, the
>> .activate, and even before the line of code that actually binds the
>> Recordset to the Datagrid.
>>
>> None of these measures seem to work.
>>
>> Can someone suggest how I can get this to either not show the form
>> until its ready to display the information or to show the form
>> completely prior to loading the data so that it doesn't 'ghost' while
>> loading?
>>
>> No doubt slower computers would really make this stand out. So I'd
>> like to avoid this behavior altogether.
>
>It all has to do with when you're loading the form, when you're loading the
>data into the Datagrid, and when you're showing the form.  You should be
>doing all of these things explicitly rather than some of them being done
>implicitly (which it sounds like is what you're doing). The other point to
>keep in mind is that screen redraws are a very low priority.  In fact, they
>only occur when you're app has nothing else to do unless you explicitly code
>it. You might re-write your code so that the datagrid doesn't get loaded
>until AFTER the form has been shown. Alternatively, load the form, load the
>data grid and then don't show the form until the datagrid is completely
>loaded.  I'm unsure about some of this because I never use data-binding and
>so don't know what, if any, differences that could make.
>
>Might help us to help you if you posted the code for this form2.method you
>kept mentioning.


Thank you Mike for your kind reply.

The code in form2 is nothing more than...


Set the DataGrid1.Datasource = Rs.Datasource.

Nothing more.

What I noticed in my app is that when the form is being loaded and
grid being filled, the rest of my app is off doing other things that
follow. For now, I've stopped this by form2.show 1. Now it opens and
displays fast, although the rest of the program waits until I close it
rather than continue on its way.

I don't understand what you mean by implicit/explicit.

How does one determine whether the form has completed its display
completely before loading up the grid? Would adding a timer to delay
firing off the code "Set DataGrid1.Datasource = ..." help or just make
it appear even more painfully slow to load?

Thanks!

Webbiz
Author
12 Jun 2009 4:42 PM
MikeD
Show quote Hide quote
"Webbiz" <nospam@forme.thanks.com> wrote in message news:1es435p9qfkvro1pju1nmgoe47tso7dtcm@4ax.com...

>
> The code in form2 is nothing more than...
>
>
> Set the DataGrid1.Datasource = Rs.Datasource.
>
> Nothing more.
>
> What I noticed in my app is that when the form is being loaded and
> grid being filled, the rest of my app is off doing other things that
> follow. For now, I've stopped this by form2.show 1. Now it opens and
> displays fast, although the rest of the program waits until I close it
> rather than continue on its way.
>
> I don't understand what you mean by implicit/explicit.

Implicit would be something that VB does on its own. Explicit would be something that is done by your code.  For example, let's just
consider the loading of a form (in below scenarios, assume form is not already loaded)

If you have the line of code

Form2.Show

Form2 is implicitly loaded by VB.

Now, if you have this code:

Load Form2
Form2.Show

You are explictly loading the form prior to showing it.  You can have other statements in between loading the form and showing it.
Loading a form does NOT show it.


>
> How does one determine whether the form has completed its display
> completely before loading up the grid? Would adding a timer to delay
> firing off the code "Set DataGrid1.Datasource = ..." help or just make
> it appear even more painfully slow to load?
>

No, there should be no need to use a timer. As I said, I don't use data-binding or data-bound controls.  My guess it you'll need to
write code in events of the DataGrid control to determine when it has finished loading all data.  What's apparently happening is
that after you set the Datasource property, execution of your code continues immediately but the DataGrid is still loading data.

--
Mike
Author
12 Jun 2009 10:11 PM
Webbiz
On Fri, 12 Jun 2009 12:42:05 -0400, "MikeD" <nob***@nowhere.edu>
wrote:

>>What's apparently happening is that after you set the Datasource property, execution of your code continues immediately but the DataGrid is still loading data.

Yes. That would seem to be the case.

>>>write code in events of the DataGrid control to determine when it has finished loading all data.

For this, I imagine that some sort of event needs to be fired off so
that my code would know when it had done its job of loading.  This is
basically the issue I'm having, knowing how to detect when
form/control has done its thing.

:-)

Webbiz
Author
12 Jun 2009 10:49 PM
MikeD
Show quote Hide quote
"Webbiz" <nospam@forme.thanks.com> wrote in message
news:0dk535999dte34mrkaeo157pevs9mm3jb8@4ax.com...
> On Fri, 12 Jun 2009 12:42:05 -0400, "MikeD" <nob***@nowhere.edu>
> wrote:
>
>>>What's apparently happening is that after you set the Datasource
>>>property, execution of your code continues immediately but the DataGrid
>>>is still loading data.
>
> Yes. That would seem to be the case.
>
>>>>write code in events of the DataGrid control to determine when it has
>>>>finished loading all data.
>
> For this, I imagine that some sort of event needs to be fired off so
> that my code would know when it had done its job of loading.  This is
> basically the issue I'm having, knowing how to detect when
> form/control has done its thing.

Hmm.  I added a DataGrid control to a form and looked over its events. I
don't see anything that stands out that looks like it'd fire when the grid's
been populated with all the data. Is there a way you can make it
synchronous?  IOW, so that when you assign the data source to the DataSource
property, it doesn't return until all data is loaded?  Again, I don't use
data-binding so I don't know if there's a way to specify this or not.

Just another example of why data-binding sucks. It removes control of things
from you, the programmer. Honestly, my best suggestion is to look into doing
this without data-binding.

Is the code which executes following setting the datasource dependent on the
grid being populated? If not, can you just move that code to a point before
you set the datasource? IOW, so your program has nothing to do until the
data is loaded and the user takes some kind of action.

Those are the only suggestions I have. Perhaps somebody who uses
data-binding (and the DataGrid) can offer something better.

--
Mike
Author
13 Jun 2009 3:13 AM
Webbiz
On Fri, 12 Jun 2009 18:49:51 -0400, "MikeD" <nob***@nowhere.edu>
wrote:


>Hmm.  I added a DataGrid control to a form and looked over its events. I
>don't see anything that stands out that looks like it'd fire when the grid's
>been populated with all the data. Is there a way you can make it
>synchronous?  IOW, so that when you assign the data source to the DataSource
>property, it doesn't return until all data is loaded?  Again, I don't use
>data-binding so I don't know if there's a way to specify this or not.

I'm actually new at this DB and Databinding thing myself. That's why I
wasn't sure how to handle this situation best.

>Just another example of why data-binding sucks. It removes control of things
>from you, the programmer. Honestly, my best suggestion is to look into doing
>this without data-binding.

That is certainly an option and not difficult to do. Though if there
is a solution that didn't involve doing it explicitedly, the
convenience of databinding is pretty nice.

>
>Is the code which executes following setting the datasource dependent on the
>grid being populated?

Not at all. It is, however, the reason the user ran the routine, and
not the datagrid display itself. The datagrid simply shows what has
occurred during calculation and what the program does following are
the results the user is looking for. So having it all stop until the
user closes the datagrid form is an inconvenience to the user.

> If not, can you just move that code to a point before
>you set the datasource?

While the code that follows is not dependant on the grid being filled,
it is dependant on the data that is being placed in the grid.

> IOW, so your program has nothing to do until the
>data is loaded and the user takes some kind of action.

Now I could allow the program to finish all its calculations and other
displays prior to opening the form and filling the grid. However, the
recordset goes through some changes following the grid fill routine.
This means the data would have to be stored temporarily and that some
routine later, that doesn't even have anything to do with this, would
have to run it and fill the grid with the stored data. It's not a
graceful way to do it IMHO.

>Those are the only suggestions I have. Perhaps somebody who uses
>data-binding (and the DataGrid) can offer something better.

I appreciate your thoughts and suggestions. I'll keep dinkering with
it.

Thanks. :-)

Webbiz