473,320 Members | 1,820 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,320 software developers and data experts.

type.Attributes names

Hi all,

i'm looking at the next problem.
i'm trying to get the names of attributes of object or of types.

example
class test
private name as string
sub new (byval test as string)
me.name = test
end sub
end class

class main
dim x as new test("hello")
end class

i now would like tto know how i can get from either the type of test
or the object the value name. i do not want the data in the attributes
but the defined name of the attributes

many thanks in advance,
Stieve
Jun 27 '08 #1
7 1140
<bs*****@gmail.comschrieb
Hi all,

i'm looking at the next problem.
i'm trying to get the names of attributes of object or of types.

example
class test
private name as string
sub new (byval test as string)
me.name = test
end sub
end class

class main
dim x as new test("hello")
end class

i now would like tto know how i can get from either the type of test
or the object the value name. i do not want the data in the
attributes but the defined name of the attributes
I've tried to understand what you are trying to achieve but I failed.
Could you please describe the result expected?

About attributes:
http://msdn2.microsoft.com/en-us/library/5x6cd29c.aspx
http://msdn2.microsoft.com/en-us/library/39967861.aspx
Armin

Jun 27 '08 #2


my final goal is to create a dynamic listview.
i would like to create a user controle where i send a collection of
unique typed objects to and it populates the listview dynamical.
i want it to use the names of the attributes of the objects as columns
and then populate it with the values in attribute.

stieve
Jun 27 '08 #3
"Stieve" <bs*****@gmail.comschrieb
>

my final goal is to create a dynamic listview.
i would like to create a user controle where i send a collection of
unique typed objects to and it populates the listview dynamical. i
want it to use the names of the attributes of the objects as columns
and then populate it with the values in attribute.
I feel sorry, I don't see any attributes in your code.
Armin
Jun 27 '08 #4
On 2008-04-16, bs*****@gmail.com <bs*****@gmail.comwrote:
Hi all,

i'm looking at the next problem.
i'm trying to get the names of attributes of object or of types.

example
class test
private name as string
sub new (byval test as string)
me.name = test
end sub
end class

class main
dim x as new test("hello")
end class

i now would like tto know how i can get from either the type of test
or the object the value name. i do not want the data in the attributes
but the defined name of the attributes

many thanks in advance,
Stieve
What do you mean by attributes? I don't see any attributes in your
code? Are you talking about properties? Either way, you'll probably
want to explore the System.Reflection namespace.

--
Tom Shelton
Jun 27 '08 #5

"Stieve" <bs*****@gmail.comwrote in message
news:5c**********************************@2g2000hs n.googlegroups.com...
>

my final goal is to create a dynamic listview.
i would like to create a user controle where i send a collection of
unique typed objects to and it populates the listview dynamical.
i want it to use the names of the attributes of the objects as columns
and then populate it with the values in attribute.

stieve
I have done something like you want. You are mixing the terms though.
Objects have properties and those properties can have attributes.

You will need to use reflection to get a list of the properties of the
object. From that collection you can dynamically create your columns. You
will then need to map the column to the property as you populate the
listview.

You can use attributes to indicate whether or not to use a certain property
as a column. The best example of this are the attributes used to control
the property grid. There are attributes used to indicated the Catagory of
the property and whether or not to show the property on the property grid.

There is alot of research that goes into what you are doing but it can be
done.

Google: Reflection - to get property list
Attributes or Property Grid to see how you use attributes to
control visibility.

Hope this helps
Lloyd Sheen
Jun 27 '08 #6
On Apr 16, 6:19*pm, Tom Shelton
<tom_shel...@YOUKNOWTHEDRILLcomcast.netwrote:
On 2008-04-16, bsti...@gmail.com <bsti...@gmail.comwrote:


Hi all,
i'm looking at the next problem.
i'm trying to get the names of attributes of object or of types.
example
class test
private name as string
sub new (byval test as string)
me.name = test
end sub
end class
class main
dim x as new test("hello")
end class
i now would like tto know how i can get from either the type of test
or the object the value name. i do not want the data in the attributes
but the defined name of the attributes
many thanks in advance,
Stieve

What do you mean by attributes? *I don't see any attributes in your
code? *Are you talking about properties? *Either way, you'll probably
want to explore the System.Reflection namespace.

--
Tom Shelton- Hide quoted text -

- Show quoted text -
I agree, i think he means name property of the objects.
Jun 27 '08 #7
Stieve wrote:
my final goal is to create a dynamic listview.
i would like to create a user controle where i send a collection of
unique typed objects to and it populates the listview dynamical.
i want it to use the names of the attributes of the objects as columns
and then populate it with the values in attribute.
An alternative for you:

To each class that you want to display in this way, add a method that
"renders" your class into a given ListView.
For consistency, you probably want to do this with an Interface.

Interface ICanBeListViewed
Function GetColumns() As String()
Sub Render( lvDisplay as ListView )
End Interface

Class X
Implements ICanBeListViewed

Function GetColumns() As String()
' Return an array of column names
Return New String() { "a", "b" }
End Function

Sub Render( lvDisplay as ListView ) _
Implements ICanBeListViewed.Render

' In here, add an Item and Subitems into the given ListView
With lvDisplay.Items.Add( "a value" )
.SubItems.Add( "b value" ) ' (I think)
End With
End Sub

End Class

Now, to load the ListView, you create Columns based on the GetColumns()
value of one of the items in your collection, then Render() each object
into the ListView.

HTH,
Phill W.
Jun 27 '08 #8

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

Similar topics

9
by: Francis Avila | last post by:
A little annoyed one day that I couldn't use the statefulness of generators as "resumable functions", I came across Hettinger's PEP 288 (http://www.python.org/peps/pep-0288.html, still listed as...
54
by: Victor Mehta | last post by:
would it matter if I decided to make a primary key a string of numbers vs actual numbers ? would it make any difference to DB2 in terms of efficiency ? why would you choose numeric over a string...
0
by: Brian B | last post by:
Is there any way to allow the user to view type member names and/or thier values, such as.... I am developing an application to create dynamic excel charts off of predefined queries in an XML...
7
by: Martin Robins | last post by:
I am currently looking to be able to read information from Active Directory into a data warehouse using a C# solution. I have been able to access the active directory, and I have been able to return...
4
by: andychambers2002 | last post by:
I'm working on a "TempFile" class that stores the data in memory until it gets larger than a specified threshold (as per PEP 42). Whilst trying to implement it, I've come across some strange...
3
by: matt.skibbs | last post by:
When we moved a project from .NET 1.1 to .NET 2.0, we ran into an issue with some code that inserts a datatable from IDataReader.GetSchemaTable() into a dataset, and then serializes the dataset to...
6
by: Demorsy | last post by:
Disappointed, this is not the first time I'm posting this kind of a request for help, but no helpful answer was posted yet. I'll try make my question as clear as I can: (1) I wish to write an...
4
by: =?Utf-8?B?QXhlbCBEYWhtZW4=?= | last post by:
Hi, I'd like to create a generic algorithm to analyse an enum's elements for custom attributes. All I have at hand is is a type name to create an enum type info from. But if I call...
11
by: Rafe | last post by:
Hi, I'm working within an application (making a lot of wrappers), but the application is not case sensitive. For example, Typing obj.name, obj.Name, or even object.naMe is all fine (as far as...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.