ユーザーがlistBoxで行った選択に応じてコンテンツを変更するDatagridviewがあります。DGV は、2 つのコンボボックス (国、製品) と 1 つのテキストボックス (数量) で構成されています。
3 つの整数を組み合わせたクラスを作成しました。このクラスは、DGV のデータソースであるリストのタイプとして使用されます。前のリストを含む別のリストもあるので、データソースのリストがあります。
DGV のデータソースは、listBox の SelectedIndex が起動されるたびに変化する BindingSource です。
私の問題は、新しい行が DGV に追加されるたびに発生します。クラスのコンストラクターを呼び出す BindingSource.AddNew を使用しますが、クラス内の各項目に値を割り当てる必要があります。そうすれば、DGV の任意のセルをクリックするたびに、空白の行が表示されなくなります。また、BS が変わって戻ってくると、もう 1 行追加されます。
私が取得したいのは空白行です - 空のコンボボックスとテキストボックスです。
ご協力いただきありがとうございます!
クラス:
    Public Class PoList
    Private _CountryID As Integer
    Private _ProductID As Integer
    Private _Quantity As Integer
    Public Sub New(ByVal CountryID As Integer, ByVal ProductID As Integer, ByVal Quantity As Integer)
        _CountryID = CountryID
        _ProductID = ProductID
        _Quantity = Quantity
    End Sub
    Private Sub New()
        _CountryID = 1
        _ProductID = 2
        _Quantity = Nothing
    End Sub
    Public Property CountryID() As Integer
        Get
            Return _CountryID
        End Get
        Set(ByVal value As Integer)
            _CountryID = value
        End Set
    End Property
    Public Property ProductID() As Integer
        Get
            Return _ProductID
        End Get
        Set(ByVal value As Integer)
            _ProductID = value
        End Set
    End Property
    Public Property Quantity() As Integer
        Get
            Return _Quantity
        End Get
        Set(ByVal value As Integer)
            _Quantity = value
        End Set
    End Property
    Public Shared Function CreateNewPoList() As PoList
        Return New PoList
    End Function
End Class
Private Sub List_AddRow(ByVal sender As Object, ByVal e As AddingNewEventArgs) Handles AllListBindingSource.AddingNew
    e.NewObject = PoList.CreateNewPoList
End Sub
新しい内部リストの作成:
AllList.Add(New List(Of PoList))
AllListBindingSource.AddNew()
AllListBindingSource.DataSource = AllList(TableCounter)
AddPoDetails.DataSource = AllListBindingSource
SelectedIndexChanged イベント:
AllListBindingSource.DataSource = AllList(AddPoList.SelectedIndex)
AddPoDetails.DataSource = Nothing
AddPoDetails.DataSource = AllListBindingSource