PC Review


Reply
Thread Tools Rate Thread

datagrid doesn't reflect changes in data (unless datatable)

 
 
Peter Bladh
Guest
Posts: n/a
 
      15th Jan 2004
Hi!

After a tip from Alex Feinman I manage to databind a datagrid to an
arraylist (thanks!). But the datagrid doesn't reflect changes in the
arraylist, unless I do the following

dg.DataSource = null;
dg.DataSource = myArrayList;

.... which doesn't seem very effective.
Is there a better way?


Regards
Peter Bladh


 
Reply With Quote
 
 
 
 
Peter Foot [MVP]
Guest
Posts: n/a
 
      15th Jan 2004
ArrayList does not expose the IBindingList interface which expose the Event
used to react to changes in the datasource. The only way to refresh the grid
therefore is to manually force it to update using the method described
below.

Peter

--
Peter Foot
Windows Embedded MVP
OpenNETCF.org Senior Advisor
www.inthehand.com | www.opennetcf.org

"Peter Bladh" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi!
>
> After a tip from Alex Feinman I manage to databind a datagrid to an
> arraylist (thanks!). But the datagrid doesn't reflect changes in the
> arraylist, unless I do the following
>
> dg.DataSource = null;
> dg.DataSource = myArrayList;
>
> ... which doesn't seem very effective.
> Is there a better way?
>
>
> Regards
> Peter Bladh
>
>



 
Reply With Quote
 
Peter Bladh
Guest
Posts: n/a
 
      15th Jan 2004
Thank you for your answer!

Anothor disadvantage with

> > dg.DataSource = null;
> > dg.DataSource = myArrayList;


is that the datagrid won't keep the "scroll location" - if the user has
scrolled down and the datagrid gets updated it will "scroll up". That kind
of behavior will probably upset the users...
Is there a way to keep the "scroll location"?


Regards / Peter Bladh


"Peter Foot [MVP]" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> ArrayList does not expose the IBindingList interface which expose the

Event
> used to react to changes in the datasource. The only way to refresh the

grid
> therefore is to manually force it to update using the method described
> below.
>
> Peter
>
> --
> Peter Foot
> Windows Embedded MVP
> OpenNETCF.org Senior Advisor
> www.inthehand.com | www.opennetcf.org
>
> "Peter Bladh" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi!
> >
> > After a tip from Alex Feinman I manage to databind a datagrid to an
> > arraylist (thanks!). But the datagrid doesn't reflect changes in the
> > arraylist, unless I do the following
> >
> > dg.DataSource = null;
> > dg.DataSource = myArrayList;
> >
> > ... which doesn't seem very effective.
> > Is there a better way?
> >
> >
> > Regards
> > Peter Bladh
> >
> >

>
>



 
Reply With Quote
 
Don Strenczewilk
Guest
Posts: n/a
 
      15th Jan 2004
Something basically like the following (but I use a DataTable) works for me:

// Save the current item's ID
int oldPsId = this.GetCurrentPackingSlipId(context);
....
> dg.DataSource = null;
> dg.DataSource = myArrayList;

....
if (oldPsId != 0) {
// Find the index of the old psid in the ArrayList
i = ArrayListIndexOfID(oldPsId); // I used datatable.find here.
if (i >= 0) {
dg.CurrentRowIndex = i;
dg.Select(i);
}
}


"Peter Bladh" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thank you for your answer!
>
> Anothor disadvantage with
>
> > > dg.DataSource = null;
> > > dg.DataSource = myArrayList;

>
> is that the datagrid won't keep the "scroll location" - if the user has
> scrolled down and the datagrid gets updated it will "scroll up". That kind
> of behavior will probably upset the users...
> Is there a way to keep the "scroll location"?
>
>
> Regards / Peter Bladh
>
>
> "Peter Foot [MVP]" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
> > ArrayList does not expose the IBindingList interface which expose the

> Event
> > used to react to changes in the datasource. The only way to refresh the

> grid
> > therefore is to manually force it to update using the method described
> > below.
> >
> > Peter
> >
> > --
> > Peter Foot
> > Windows Embedded MVP
> > OpenNETCF.org Senior Advisor
> > www.inthehand.com | www.opennetcf.org
> >
> > "Peter Bladh" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Hi!
> > >
> > > After a tip from Alex Feinman I manage to databind a datagrid to an
> > > arraylist (thanks!). But the datagrid doesn't reflect changes in the
> > > arraylist, unless I do the following
> > >
> > > dg.DataSource = null;
> > > dg.DataSource = myArrayList;
> > >
> > > ... which doesn't seem very effective.
> > > Is there a better way?
> > >
> > >
> > > Regards
> > > Peter Bladh
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Alex Feinman
Guest
Posts: n/a
 
      15th Jan 2004
In another sample I show how to scroll the datagrid into a particular
position: http://www.alexfeinman.com/dowload.a...ScrollGrid.zip

HTH'
Alex

Peter Bladh wrote:
> Thank you for your answer!
>
> Anothor disadvantage with
>
>
>>>dg.DataSource = null;
>>>dg.DataSource = myArrayList;

>
>
> is that the datagrid won't keep the "scroll location" - if the user has
> scrolled down and the datagrid gets updated it will "scroll up". That kind
> of behavior will probably upset the users...
> Is there a way to keep the "scroll location"?
>
>
> Regards / Peter Bladh
>
>
> "Peter Foot [MVP]" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
>
>>ArrayList does not expose the IBindingList interface which expose the

>
> Event
>
>>used to react to changes in the datasource. The only way to refresh the

>
> grid
>
>>therefore is to manually force it to update using the method described
>>below.
>>
>>Peter
>>
>>--
>>Peter Foot
>>Windows Embedded MVP
>>OpenNETCF.org Senior Advisor
>>www.inthehand.com | www.opennetcf.org
>>
>>"Peter Bladh" <(E-Mail Removed)> wrote in message
>>news:(E-Mail Removed)...
>>
>>>Hi!
>>>
>>>After a tip from Alex Feinman I manage to databind a datagrid to an
>>>arraylist (thanks!). But the datagrid doesn't reflect changes in the
>>>arraylist, unless I do the following
>>>
>>>dg.DataSource = null;
>>>dg.DataSource = myArrayList;
>>>
>>>... which doesn't seem very effective.
>>>Is there a better way?
>>>
>>>
>>>Regards
>>>Peter Bladh
>>>
>>>

>>
>>

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query via Import External Data doesn't reflect revised syntax Melanie Microsoft Excel Misc 0 16th Jul 2008 05:28 PM
Datagrid Datatable Insert rows and data =?Utf-8?B?Um9i?= Microsoft Dot NET 6 22nd Nov 2005 04:19 PM
Datagrid doesn't reflect changes in datasource =?Utf-8?B?UmVuw6kgVGl0dWxhZXI=?= Microsoft Dot NET Framework Forms 2 26th Nov 2004 03:39 PM
datagrid doesn't reflect addnew to dataset =?Utf-8?B?cG9seW5vbWlhbDVk?= Microsoft ADO .NET 19 27th Jun 2004 11:37 AM
Imported data query doesn't reflect database JD Microsoft Excel Misc 0 5th May 2004 04:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:01 AM.