I have a class called "car" with - I have no ideia how to say this in english - "data members" as the following:

Public pneu As classDoor
Public mat As classTire
Public length As Double

And so on. All the related classes have null constructors. I have a tab control where each tab is equivalent a one of this features. The tab "Tire" with respect to "pneu", for example, has the following properties:

Public Property materialh As String()
    Set(value As String())
        mat = value
    End Set
        Return mat
    End Get
End Property

Public Property diameterh As String()
    Set(value As String())
        diam = value
    End Set
        Return diam
    End Get
End Property

As you can realize the "data members" are arrays and I can resize them dynamically using "Redim". What I want to do is to display these properties on a DataGridView - BUT NOT THE ENTIRE OBJECT, JUST SOME PROPERTIES. Each row of the datagridview is one of these properties - again, not all - and the number of columns depends on another parameter I have. And everytime I change the values on cells I would like to change the value of the property on my object - something like a binding. I was able to do these two tasks separately (the binding and the need to input only some properties) using stuff like BindingSource, but never on the same time. Can someone help ? It seems simple, but I just can´t do it.


Ricardo S.

Recommended Answers

All 5 Replies

.... and you did at some pont set the dgv's datasource to your bindingsource, did you?

Sure, but appears nothing. The problem is that the properties are arrays. If the property is just a single value, it appears with no problem on dgv. There are other problems like the fact that the columns are the ones that are populated and I would like that to happen the rows. Othe thing I dislike is that I have to use the property name and not the name I want to put in the column.


Ricardo S.

How about use dataset.datatable i.o. arrays. It's really very easy (once you get that hang of it). I guess the dgv needs some kind of header for it's columns no?

I am using arrays because I need to deserialize and serialize my whole object into an .xml file. Do you mean create a property of the type "Datatable" ? Can you give more details on your idea ?

Basically you could oDt = new datatable. Then for each column you could oDt.columns.add("col1..x",gettype(String)). Mind you gettype might be double or integer, or whatever you want.

And finally for each line in your array you could `

Dim oRow as datarow = odt.rows.add
oRow("column1..x") = <array(line,column1..x>

I've never xml'd anything in my life but I'll be damned if to serialize a datatable is a complicated thing to do. Did not check this assertion. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.