Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

wpf combo bind to list(of T syntax question

$
0
0

With this code, a combobox is bound very simply with 2 items:

            PartBCombo = New List(Of PartBBilling_Combobox)() From { _
               New PartBBilling_Combobox() With { _
                   .PartBLookup_CPTCode = "D0001",
                   .PartBLookup_ProcedureDescription = "test" _
               },
               New PartBBilling_Combobox With { _
                   .PartBLookup_CPTCode = "D2222",
                   .PartBLookup_ProcedureDescription = "Another test" _
               }
            }

How do I change this to bind with database values?

I tried this code but only the very last database row is bound:

            If Reader.HasRows Then
                While Reader.Read()
                    PartBCombo = New List(Of PartBBilling_Combobox)() From { _
                       New PartBBilling_Combobox() With { _
                           .PartBLookup_CPTCode = Reader("CPT").ToString,
                           .PartBLookup_ProcedureDescription = Reader("ProcedureName").ToString
                       }}
                End While
            End If

I'm assuming the "New List(Of..." code just overwrites the previous rows.  I get compile errors if I take out the "New..".

Class definition:

        Public Property PartBCombo As List(Of PartBBilling_Combobox)
            Get
                Return _PartBCombo
            End Get
            Set(value As List(Of PartBBilling_Combobox))
                _PartBCombo = value
            End Set
        End Property
        Private _PartBCombo As List(Of PartBBilling_Combobox)


Thanks.



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>