473,757 Members | 9,145 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
DataGridTableSt yle and added DataGridTextBox Columns to it in the correct
order which works fine if the dataGrid.dataSo urce = "ArrayList" , but it
doesn't work for my IBindingList wrapper.
If i bind the datasource to the arraylist method then the
ListChangedEven tHandler 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 DataGridTableSt yle. Any hints (with examples) would be much
appreciated.

Thanks

Matt
Nov 17 '05 #1
3 1793
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
"DefaultSty le" 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****@bearwag ner.com> wrote in message
news:%2******** ********@tk2msf tngp13.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
DataGridTableSt yle and added DataGridTextBox Columns to it in the correct
order which works fine if the dataGrid.dataSo urce = "ArrayList" , but it
doesn't work for my IBindingList wrapper.
If i bind the datasource to the arraylist method then the
ListChangedEven tHandler 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 DataGridTableSt yle. 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 DataGridColumnS tyle".

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 "clsGridRow s", 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****@bearwag ner.com> wrote in message
news:um******** ******@TK2MSFTN GP11.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 "CustomStyl e()" but when i start the timer to change
the data the grid is only updated if i uncomment the datagrid1.refre sh();
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.refre sh())
because the ListChangedEven t 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**********@h otmail.com> wrote in message
news:%2******** ********@tk2msf tngp13.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
"DefaultSty le" 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****@bearwag ner.com> wrote in message
news:%2******** ********@tk2msf tngp13.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
> DataGridTableSt yle and added DataGridTextBox Columns to it in the
> correct
> order which works fine if the dataGrid.dataSo urce = "ArrayList" , but it
> doesn't work for my IBindingList wrapper.
> If i bind the datasource to the arraylist method then the
> ListChangedEven tHandler 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 DataGridTableSt yle. 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**********@h otmail.com> wrote in message
news:ec******** ******@TK2MSFTN GP10.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 DataGridColumnS tyle".

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 "clsGridRow s", 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****@bearwag ner.com> wrote in message
news:um******** ******@TK2MSFTN GP11.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 "CustomStyl e()" but when i start the timer to change the data the grid is only updated if i uncomment the datagrid1.refre sh(); 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.refre sh()) because the ListChangedEven t 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**********@h otmail.com> wrote in message
news:%2******** ********@tk2msf tngp13.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
"DefaultSty le" 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****@bearwag ner.com> wrote in message
news:%2******** ********@tk2msf tngp13.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
> DataGridTableSt yle and added DataGridTextBox Columns to it in the
> correct
> order which works fine if the dataGrid.dataSo urce = "ArrayList" , but it > doesn't work for my IBindingList wrapper.
> If i bind the datasource to the arraylist method then the
> ListChangedEven tHandler 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 DataGridTableSt yle. 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
1189
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 collection and returns the new object. The SupportsChangeNotification property returns true and the appropriate ListChangedEventArgs are used in the ListChanged event. All fine no problem. However:
0
2375
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 IBindingList that I haven't figured out yet, how to determine which DataGrid column header I clicked on so I can do a custom sort. Right now the sort is rotating just to see that everything works. There are two pieces of the IBindingList that I didn't...
5
2532
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 the column heading is not in the right order, for eg. I want "ID" column to be the first column but it showed as the second column. Another problem is that anyway i can leave a blank row in the grid to add a new row automatically if the user...
7
4232
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 assume the data types and thus can't sort them. I thought about implementing IComparable, but I don't see how that would work since it doesn't apply generically to all the fields/properties of the class. Thanks.
15
9185
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 - loop through each row, extracting the data held in each column. I can't figure out how to do that. It has to be simple, can somebody please help me? --
5
6692
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 within the class contained in the arraylist is updated. i do not want to use datagrid.refresh() because the data updates randomly and often frequently and refreshing the whole grid several times a second is expensive and causes a flicker.
5
4502
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 .Net desktop application using C# and framework version 1.1 I have a arraylist of some objects of the same type and I am showing
0
933
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 doesn't seem to be the case. When the grid is sorted, ApplySort is never called. Now I'm assuming the datagrid doesn't call ApplySort, and in the sort command event, I just need to call it myself. Is this correct? Or should the datagrid be...
16
2028
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 reference to the arraylist item the current row points to? 2 - Is it possible to sort the grid? Many thanks in advance.
0
9489
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10072
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9906
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9737
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7286
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6562
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5172
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.