Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 999661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:23:22+00:00 2026-05-16T07:23:22+00:00

I have a custom item class (basically two string values with associated properties), as

  • 0

I have a custom item class (basically two string values with associated properties), as below:

Public Class itmDataDetails
    Private _strDataName As String
    Private _strDataValue As String

    Public Property strDataName() As String
        Get
            Return _strDataName
        End Get
        Set(ByVal value As String)
            _strDataName = value
        End Set
    End Property

    Public Property strDataValue() As String
        Get
            Return _strDataValue
        End Get
        Set(ByVal value As String)
            _strDataValue = value
        End Set
    End Property

    Public Sub New(Optional ByVal strDataNameIn As String = "", Optional ByVal strDataValueIn As String = "")
        strDataName = strDataNameIn
        strDataValue = strDataValueIn
    End Sub

and an ObservableCollection wrapper class around this. I’d like to transpose this ObservableCollection (that is, make the data names into the columns and their associated values into the rows) for display in a WPF ListView.

Here’s what I have so far:

Private Sub Transpose()
    Dim colGroupedValues = From x In MyBase.Items Group x By Key = x.strDataName Into Group Select strName = Key, colValues = Group
    MyBase.Clear()
    For Each x In colGroupedValues
        MyBase.Add(x)
    Next
End Sub

Naturally, this doesn’t work as x cannot be added to the ObservableCollection(Of itmDataDetails). Any suggestions on how to accomplish this? I don’t know LINQ that well, so I wouldn’t be surprised to discover I’m doing it wrong.

Thanks in advance, everyone.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T07:23:23+00:00Added an answer on May 16, 2026 at 7:23 am

    So I think I was asking the wrong question here. What I really wanted was to have each column in a GridView be set to the DataName part of itmDataDetails and its corresponding records be set to the DataValue.

    To do this, I followed the helpful guide at: http://weblogs.asp.net/psheriff/archive/2010/03/08/using-a-wpf-listview-as-a-datagrid.aspx

    So the whole thing is replaced by:

    Private Sub FillDataList()
       Dim strConnectionString As String = "INSERT CONNECTION INFO HERE"
       Dim strCommandString As String = "INSERT QUERY HERE"
       Dim objCommand As New OleDb.OleDbCommand(strCommandString)
       Dim objConnection As New OleDb.OleDbConnection(strConnectionString)
       Dim objAdapter As New OleDb.OleDbDataAdapter
       Dim ds As New DataSet
    
       objConnection.Open()
       objAdapter.SelectCommand = objCommand
       objCommand.Connection = objConnection
       objAdapter.Fill(ds)
       lsvData.View = BuildDataView(ds)
       lsvData.DataContext = ds.Tables(0)
       lsvData.SetBinding(ListView.ItemsSourceProperty, New Binding)
       objConnection.Close()
    
    End Sub
    
    Public Function BuildDataView(ByVal ds As DataSet) As GridView
        Dim gv As New GridView
        For Each item As DataColumn In ds.Tables(0).Columns
            Dim gvc As New GridViewColumn
            gvc.DisplayMemberBinding = New Binding(item.ColumnName)
            gvc.Header = item.ColumnName
            gvc.Width = [Double].NaN
            gv.Columns.Add(gvc)
        Next
        Return gv
    End Function
    

    This gives me what I wanted. Sorry for the misunderstanding, if there was any. I’ll still accept an answer that does this task better than my solution (to be charitable, etc.)

    I also suspect that the database engine doesn’t matter here, so you could probably do something similar for Oracle databases, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some custom type: [RdfSerializable] public class Item { [RdfProperty(true)] public string Name
So I have a custom type Foo : public class Foo { public string
I have Custom List to display image with it's name like below... public class
I have the following classes : public abstract class Item { //... } public
I have a custom CursorAdapter and it looks like : public class LabelAdapter extends
I have a custom view that extends LinearLayout, with these constructors: public class CustomView
I have the following ListView with a custom list item: I would like to
I have a custom QGraphicsView and a custom QGraphicsItem. I want the Item to
I have a TFS 2010 Work Item Type with a custom field called Requested
I've defined a custom content type - news. I also have a menu item

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.