Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I want to set the DataSource Property of a listview and of a combobox to an array of datarows.

 

This is the Code:

Private Sub fillCBKoerperTeile() '(ByVal FilterExpression As String, ByVal Sort As String)
   
   Dim rows() As Data.DataRow
   Dim dr As Data.DataRow

   Try
     rows = dtKoerperTeile.Select(FilterExpression, Sort)
     cbKoerperTeile.DataSource = rows
     cbKoerperTeile.ValueMember = "Name"
     cbKoerperTeile.DisplayMember = cbKoerperTeile.ValueMember
     
   Catch e As Exception
     Throw New ApplicationException(CodeLoc & " Error!", e)
   Finally
     dr = Nothing
   End Try

 End Sub

 

The 'Name' column does exist but the ComboBox shows only the type of each datarow not the contents! If I set the datasource to a datatable, the correct column is shown in the combobox/listview.

 

Many Greetings

 

Hans

Posted

Thanks for the reply. I just wanted to post this solution. I found it in a book called Visual Basic.Net. But there is still a problem. If I want to search for a value in a Dataview, I must set the dataview.sort property to the column name. But if I do so the listview is no more sorted the way I want it to be sorted. And if I set .Sort back to the previous value the selection I made before with the .Find Method is lost.

 

 

 

 

Regards

 

Hans

 

       rows = dtSymptome.Select("Text like '" & MakeFitForQuery(txtSymptom.Text) & "*'")
       If UBound(rows) < 0 Then
         rows = dtSymptome.Select("Text like '*" & MakeFitForQuery(txtSymptom.Text) & "*'")
       End If
       mDontUpdateText = True
       Dim oldSort As String = dvSymptome.Sort
       dvSymptome.Sort = "ID"
       For Each row In rows

         SymptomID = row!ID

         find = dvSymptome.Find(SymptomID)
         'find = findLstIndex(SymptomID)
         If find >= 0 Then lstSymptome.SetSelected(find, True)
       Next row
       dvSymptome.Sort = oldSort
       mDontUpdateText = False

 

if I write my own procedure to find the value it is way to slow......

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...