Iv got a StatisticsConta iner object that contains an arraylist of
objects of different types, all inherited from class Statistic. The
statistics class has 2 string public properties, name and stringValue.
The classes that inherit from it use those two properties, plus several
properties of their own of types double and vector. I need to display
this StatisticsConta iner class on a datagrid, but I'm having problems
because each of the classes have some different properties. The
datagrid automatically binds to all public properties of the first
entry, but most of these (all but stringValue), are actually unique to
the first entry. What results if i add another entry to the arraylist
is an exception from the reflection namespace. I need to do one of
three things:
1. force the datagrid to display only the properties common to the
statistic base class.
or
2. have the datagrid display little plus marks allowing me to expand
each entry and see all of this unique properties.
or
3. (the best) do both.
The datagrid control is completely confusing me with its myriad
collections of styles. I have no reference books (beyond what i can
find on the web), so I would greatly appreciate some help. 1 1507
Hi,
[Inline]
"Michael Gorbach" <mg******@gmail .com> wrote in message
news:11******** *************@g 43g2000cwa.goog legroups.com... Iv got a StatisticsConta iner object that contains an arraylist of objects of different types, all inherited from class Statistic. The statistics class has 2 string public properties, name and stringValue. The classes that inherit from it use those two properties, plus several properties of their own of types double and vector. I need to display this StatisticsConta iner class on a datagrid, but I'm having problems because each of the classes have some different properties. The datagrid automatically binds to all public properties of the first entry, but most of these (all but stringValue), are actually unique to the first entry. What results if i add another entry to the arraylist is an exception from the reflection namespace. I need to do one of three things: 1. force the datagrid to display only the properties common to the statistic base class.
This is possible by implementing your own custom collection which implements
ITypedList :
using System.Reflecti on;
using System.Componen tModel;
using System.Collecti ons;
public class StatisticsConta iner : CollectionBase, ITypedList
{
public int Add( Statistic a )
{
return List.Add( a );
}
public Statistic this[int i]
{
get { return (Statistic)List[i]; }
}
// .......
// implement other collection properties the same way ( using List )
// .......
// implementation of ITypedList
public PropertyDescrip torCollection GetItemProperti es(PropertyDesc riptor[]
listAccessors)
{
if ( listAccessors == null || listAccessors.L ength == 0 )
{
PropertyDescrip torCollection pdc = new
PropertyDescrip torCollection(n ull);
// Using reflection to keep the order of fields
// typeof( Base-Class-Name )
foreach( PropertyInfo pi in typeof(Statisti c).GetPropertie s() )
{
// by default properties are included,
// unless they have the [BindableAttribu te(false)].
object[] o = pi.GetCustomAtt ributes(typeof( BindableAttribu te),
false );
if ( o.Length == 0 || ((BindableAttri bute)o[0]).Bindable )
{
pdc.Add( TypeDescriptor. CreateProperty( typeof(Statisti c),
pi.Name, pi.PropertyType ) );
}
}
return pdc;
}
else
{
// only required for hierarchical collections, not implemented,
// ask if you need help with this
return null;
}
}
// implementation of ITypedList
public string GetListName(Pro pertyDescriptor[] listAccessors)
{
if ( listAccessors == null || listAccessors.L ength == 0 )
{
return this.GetType(). Name;
}
else
{
// only required for hierarchical collections, not implemented,
// ask if you need help with this
return null;
}
}
}//end-class
HTH,
Greetings
or 2. have the datagrid display little plus marks allowing me to expand each entry and see all of this unique properties.
or
3. (the best) do both.
The datagrid control is completely confusing me with its myriad collections of styles. I have no reference books (beyond what i can find on the web), so I would greatly appreciate some help. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Shane |
last post by:
I made a Database in MS Access, and i want to try to port
it over to VB.NET. One thing i have is a subform that is a
datasheet. what I want to know, is there away to make the
data grid to have combo boxes or is there away edit the
data grid some how?
Shane
|
by: Charles Astwood |
last post by:
Hi, just starting out working my way round C Sharp and aspx.
Used to write all my sites in asp and just need a few pointers in how to
display data.
I have made a connection to my SQL2000 database with SqlConnection as I
think this is the fastest and best?
I have also written my SELECT statement, but am confused in how to display
this data not in a Table as all the examples on the web seem to want me to
|
by: VM |
last post by:
When I display data to a Windows datagrid I usually fill the underlying
table (in another class) and then, once it contains all the data, I attach
it to the grid. But there are some processes that involve large amounts of
data so the user won't be able to see anything in the grid until after the
table's already filled up (usually 40-60 secs with these large processes).
Is it possible (without changing the process of filling the table...
|
by: MikeY |
last post by:
Hi everyone,
In C#, is there a easy way of display files (ie. mp3 files) to a datagrid?
If someone can provide me with some code, or advice I would appreciated it.
Thanks in advance.
MikeY
|
by: vinayak |
last post by:
Hi
I am displaying data in Datagrid in ASP.NET with
Edit/Update functionality for each row. On the same page I
have 2 Button controls which submits the request to
server. These button controls are Web Control & not HTML
control. One of these buttons whose title is Delete is
added on the aspx page in design view & also I double
clicked on this button in design view to get the onclick
code for this button in the code behind page. & for...
| |
by: Ray |
last post by:
ASP.NET Newbie ?
I have a populated datagrid on my .aspx page, I want to open a second
window without all the extra fluff (nav bar, menus, etc) and display a
printer friendly version of my datagrid. I'm looking for ideas on how
to pass the data to the second page without making a second request
back to the database? Passing the data as a dialog argument in a
window.ShowModelDialog is really not an option because of the possible
data...
|
by: Pacific Design Studios |
last post by:
I have a DataGrid on Form1 that displays a small amount of information about
employees.
On Form2 I want to have all the data displaying in text boxes about the
employee selected in the datagrid on form 1.
Is there a Id in the datagrid I can use to find out which user was selected
or which record was highlighted when double clicked.
Something like: John Thomas Employee Id 2637 was selected on Form1 and the
recordset on Form2 would use...
|
by: Aaron |
last post by:
Complete code follows.
I am new to .NET programming (and programming in general) and I am having a
difficult time understanding how to fill a variable in one sub, and then
access it from another. I have tried declaring them as shared, public,
friend, etc and I always get an error stating that something is not valid
on a local variable declaration.
For example, in the following code for Sub DataGrid_Select, I have
CurrentID and...
|
by: Death |
last post by:
Hi all
I am having some trouble on displaying datagrid data from my database
as i am a beginner for this
The error is when calling the DBCommand . It show incorrect syntax near
User. But User is the table in my server. Did i do anything wrong?
Pls advice .Thanks
Below is the code sample :
|
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...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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,...
|
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |