473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

datagrid bound to IBindingList problem

Hi, is there any way to format and order the columns displayed in a datagrid
bound to a class that inherits from IBindingList? i have used
DataGridTableStyle and added DataGridTextBoxColumns to it in the correct
order which works fine if the dataGrid.dataSource = "ArrayList", but it
doesn't work for my IBindingList wrapper.
If i bind the datasource to the arraylist method then the
ListChangedEventHandler is never invoked and my grid only updates if i
refresh the currencymanager or the grid itself but obviously this does not
satisfy the requirement of displying "live" data.

to summarise, i can update my grid live when bound to my IBindingList class
that wraps round my data class but i can't set the order of the columns at
runtime using DataGridTableStyle. Any hints (with examples) would be much
appreciated.

Thanks

Matt
Nov 17 '05 #1
3 1781
If the style isn't being applied, then the style isn't being mapped
correctly to your datasource. You can have several styles bound to a grid,
but the one that gets used is when the MappingName of the style matches the
Name (ie: DataTable.Name) of the DataSource. I'm not an expert, but this is
where I would look at solving your problem. I think there is a
"DefaultStyle" property on the grid you could look at. Or does the
IBindingList interface supply a "Name" property? This must match the
mapping name of the style you have.

An excellent article on the innerworkings of the DataGrid and how it binds
to a datasource, is by Chris Sano.
http://msdn.microsoft.com/smartclien...lumnstyle1.asp
"Matthew Woods" <mw****@bearwagner.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi, is there any way to format and order the columns displayed in a
datagrid
bound to a class that inherits from IBindingList? i have used
DataGridTableStyle and added DataGridTextBoxColumns to it in the correct
order which works fine if the dataGrid.dataSource = "ArrayList", but it
doesn't work for my IBindingList wrapper.
If i bind the datasource to the arraylist method then the
ListChangedEventHandler is never invoked and my grid only updates if i
refresh the currencymanager or the grid itself but obviously this does not
satisfy the requirement of displying "live" data.

to summarise, i can update my grid live when bound to my IBindingList
class
that wraps round my data class but i can't set the order of the columns at
runtime using DataGridTableStyle. Any hints (with examples) would be much
appreciated.

Thanks

Matt

Nov 17 '05 #2
if you want to read up on DataGrids, I really suggest you find that article.
It is really well written, and will give you a strong foundation for using
the grid, which I think is a pretty complicated UI tool. Google Chris Sano
and " Styling with the DataGridColumnStyle".

As for your style not being applied, I checked your source, and although you
are changing your datasource, you are not telling the Table Style to be
applied to the new datasource... it will only be applied to a datasource
named "ArrayList". If you change this to "clsGridRows", it will style as
expected. This is because, for example with a DataSet, you can have several
tables viewable through a DataGrid, and each table can have its own style,
so when the grid displays a table, it looks for a style that matches the
table, or provides a default style if it isn't found. So, you switched the
datasource, but the style was still looking for the arraylist.
"Matthew Woods" <mw****@bearwagner.com> wrote in message
news:um**************@TK2MSFTNGP11.phx.gbl...
Thanks John, i didn't have too much success with the link you provided so
i
have zipped up a test project which highlights the problem. when i comment
out lines labeled "Method 2" i am binding an arraylist to the grid which
correctly applies the "CustomStyle()" but when i start the timer to change
the data the grid is only updated if i uncomment the datagrid1.refresh();
line in the timer.
when lines marked Method 1 are commented out and Method 2 are uncommented,
the grid refreshes correctly (without the need for a datagrid1.refresh())
because the ListChangedEvent is fired correctly BUT i cannot set the
style.

perhaps you (or anyone else for that matter, all help appreciated) could
take a quick look at the code, add any appropriate changes and re-post the
code.

Thanks
Matt

"John Richardson" <j3**********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
If the style isn't being applied, then the style isn't being mapped
correctly to your datasource. You can have several styles bound to a

grid,
but the one that gets used is when the MappingName of the style matches

the
Name (ie: DataTable.Name) of the DataSource. I'm not an expert, but this

is
where I would look at solving your problem. I think there is a
"DefaultStyle" property on the grid you could look at. Or does the
IBindingList interface supply a "Name" property? This must match the
mapping name of the style you have.

An excellent article on the innerworkings of the DataGrid and how it
binds
to a datasource, is by Chris Sano.

http://msdn.microsoft.com/smartclien...lumnstyle1.asp


"Matthew Woods" <mw****@bearwagner.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
> Hi, is there any way to format and order the columns displayed in a
> datagrid
> bound to a class that inherits from IBindingList? i have used
> DataGridTableStyle and added DataGridTextBoxColumns to it in the
> correct
> order which works fine if the dataGrid.dataSource = "ArrayList", but it
> doesn't work for my IBindingList wrapper.
> If i bind the datasource to the arraylist method then the
> ListChangedEventHandler is never invoked and my grid only updates if i
> refresh the currencymanager or the grid itself but obviously this does not > satisfy the requirement of displying "live" data.
>
> to summarise, i can update my grid live when bound to my IBindingList
> class
> that wraps round my data class but i can't set the order of the columns at > runtime using DataGridTableStyle. Any hints (with examples) would be much > appreciated.
>
> Thanks
>
> Matt
>
>



Nov 17 '05 #3
Fantastic! Thank you so much. "If you change this to 'clsGridRows'" was
exactly the sentence i have been scouring the internet for 3 days to read. I
have made the appropriate changes to my code and the writers block has
passed.
Thanks,
Matt

PS. i read with interest the article you advised and i will be using some of
the techniques at a later stage in my project.

"John Richardson" <j3**********@hotmail.com> wrote in message
news:ec**************@TK2MSFTNGP10.phx.gbl...
if you want to read up on DataGrids, I really suggest you find that article. It is really well written, and will give you a strong foundation for using
the grid, which I think is a pretty complicated UI tool. Google Chris Sano and " Styling with the DataGridColumnStyle".

As for your style not being applied, I checked your source, and although you are changing your datasource, you are not telling the Table Style to be
applied to the new datasource... it will only be applied to a datasource
named "ArrayList". If you change this to "clsGridRows", it will style as
expected. This is because, for example with a DataSet, you can have several tables viewable through a DataGrid, and each table can have its own style,
so when the grid displays a table, it looks for a style that matches the
table, or provides a default style if it isn't found. So, you switched the datasource, but the style was still looking for the arraylist.
"Matthew Woods" <mw****@bearwagner.com> wrote in message
news:um**************@TK2MSFTNGP11.phx.gbl...
Thanks John, i didn't have too much success with the link you provided so i
have zipped up a test project which highlights the problem. when i comment out lines labeled "Method 2" i am binding an arraylist to the grid which
correctly applies the "CustomStyle()" but when i start the timer to change the data the grid is only updated if i uncomment the datagrid1.refresh(); line in the timer.
when lines marked Method 1 are commented out and Method 2 are uncommented, the grid refreshes correctly (without the need for a datagrid1.refresh()) because the ListChangedEvent is fired correctly BUT i cannot set the
style.

perhaps you (or anyone else for that matter, all help appreciated) could
take a quick look at the code, add any appropriate changes and re-post the code.

Thanks
Matt

"John Richardson" <j3**********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
If the style isn't being applied, then the style isn't being mapped
correctly to your datasource. You can have several styles bound to a

grid,
but the one that gets used is when the MappingName of the style matches

the
Name (ie: DataTable.Name) of the DataSource. I'm not an expert, but this
is
where I would look at solving your problem. I think there is a
"DefaultStyle" property on the grid you could look at. Or does the
IBindingList interface supply a "Name" property? This must match the
mapping name of the style you have.

An excellent article on the innerworkings of the DataGrid and how it
binds
to a datasource, is by Chris Sano.

http://msdn.microsoft.com/smartclien...lumnstyle1.asp

"Matthew Woods" <mw****@bearwagner.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
> Hi, is there any way to format and order the columns displayed in a
> datagrid
> bound to a class that inherits from IBindingList? i have used
> DataGridTableStyle and added DataGridTextBoxColumns to it in the
> correct
> order which works fine if the dataGrid.dataSource = "ArrayList", but it > doesn't work for my IBindingList wrapper.
> If i bind the datasource to the arraylist method then the
> ListChangedEventHandler is never invoked and my grid only updates if i > refresh the currencymanager or the grid itself but obviously this

does not
> satisfy the requirement of displying "live" data.
>
> to summarise, i can update my grid live when bound to my IBindingList
> class
> that wraps round my data class but i can't set the order of the
columns at
> runtime using DataGridTableStyle. Any hints (with examples) would be

much
> appreciated.
>
> Thanks
>
> Matt
>
>



Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Phillip | last post by:
I have a DataGrid bound to a custom collection that implements IBindingList. The collection returns true for AllowNew. The collections AddNew() method creates a new object, adds it to the...
0
by: David Elliott | last post by:
I have a Collection that inherits from CollectionBase and Implements IBindingList which I have bound to a DataGrid. So far everything works fine. However, I am missing one piece to the...
5
by: K | last post by:
I created a collection which is derived from ArrayList and implements IBindingList and ITypedList. Then I bound the DataSource of a data grid into the collection. It could show up the data but...
7
by: Pete Davis | last post by:
A different question this time. I have a DataGrid bound to a collection. Is there any way for me to allow sorting? The DataGrid.AllowSorting=true doesn't work, but that's probably because it can't...
15
by: Rik Brooks | last post by:
I find it amazing that I am quickly able to find answers to obscure questions but simple ones elude me. I have a datagrid that I've bound, no problem at all. Now I want to - programatically -...
5
by: Matthew Woods | last post by:
bool A = Is this the right place to ask this question? if (A) { Where can i find a good example of an ArrayList bound to a datagrid that automatically updates the grid when the public data...
5
by: nadeem_far | last post by:
Hello All, I have been trying to solve the following issue and it seems like there is no solution available any where and maybe people at Microsoft should may be of some help. I am writing a...
0
by: Narshe | last post by:
I have a collection that implements IBindingList and I have it bound to a datagrid. It was my understanding that the datagrid would handle everything once IBindingList was implemented, but this...
16
by: stojilcoviz | last post by:
I've a datagrid whose datasource is an arraylist object. The arraylist holds many instances of a specific class. I've two questions about this: 1 - Is there a way by which I can obtain a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.