2016-10-18 1 views
0

많은 온라인 자습서에도 불구하고이 방법이 어떻게 작동하는지 아직 이해하지 못했습니다. 사용자가 행당 주소를 입력 할 수있는 radgridview가 있습니다. 먼저 우편 번호를 입력하라고합니다. 도시와 주정부는 우편 번호와 일치하는 데이터베이스에서 제공됩니다. 따라서 우편 번호가 입력되는 즉시 radgridview를 업데이트해야합니다.ObservableCollection 및 INotifyPropertyChanged를 사용하는 WPF Radgridview

INotifyProperty를 사용하는 것이 좋습니다. 컬렉션을 업데이트 할 수는 있지만 업데이트 할 DataGrid를 가져올 수 없습니다.

보기 모델 :

    Dim shipCS As New ShipTo 
        shipCS.shipCity = GetCityAndState.CityLookup(CStr(CType(dgShippingAddresses.SelectedItem, ShipTo).shipZip)) 
        shipCS.shipState = GetCityAndState.StateLookup(CStr(CType(dgShippingAddresses.SelectedItem, ShipTo).shipZip)) 

XAML :

Public Class ShipTo 
Implements INotifyPropertyChanged 

Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged 

Private Sub NotifyPropertyChanged(ByVal info As String) 
    RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(info)) 
End Sub 

Public Property shipAddressType As String = String.Empty 
Public Property orderID As String = String.Empty 
Public Property shipName As String = String.Empty 
Public Property shipAddr1 As String = String.Empty 
Public Property shipAddr2 As String = String.Empty 

Private _shipCity As String 
Public Property shipCity As String 
    Get 
     Return _shipCity 
    End Get 
    Set(value As String) 
     _shipCity = value 
     NotifyPropertyChanged("shipZip") 
    End Set 
End Property 

Private _shipState As String 
Public Property shipState As String 
    Get 
     Return _shipState 
    End Get 
    Set(value As String) 
     _shipState = value 
     NotifyPropertyChanged("shipZip") 
    End Set 
End Property 

Public Property shipZip As String = String.Empty 

코드 도시와 국가를 찾을 수

도움을 주시면 감사하겠습니다. 감사.

+0

응답이 없기 때문에 나는 기초가 떨어져서 파기를 계속해야한다고 생각합니다. – EManning

답변

0

나는 마침내 이것이 잘 작동하도록했습니다. 여기에 어려움을 겪고 다른 사람이 내 솔루션의 경우 : 우편 번호는 데이터 그리드에 입력 이제

Private _shipSelected As Boolean 
Public Property shipSelected As Boolean 
    Get 
     Return _shipSelected 
    End Get 
    Set(value As Boolean) 
     _shipSelected = value 
     NotifyPropertyChanged("shipSelected") 
    End Set 
End Property 

Public Property shipAddressType As String = String.Empty 
Public Property orderID As String = String.Empty 
Public Property shipName As String = String.Empty 
Public Property shipAddr1 As String = String.Empty 
Public Property shipAddr2 As String = String.Empty 

Private _shipCity As String 
Public Property shipCity As String 
    Get 
     Return _shipCity 
    End Get 
    Set(value As String) 
     _shipCity = value 
     NotifyPropertyChanged("shipCity") 
    End Set 
End Property 

Private _shipState As String 
Public Property shipState As String 
    Get 
     Return _shipState 
    End Get 
    Set(value As String) 
     _shipState = value 
     NotifyPropertyChanged("shipState") 
    End Set 
End Property 

Private _shipZip As String 
Public Property shipZip As String 
    Get 
     Return _shipZip 
    End Get 
    Set(value As String) 
     _shipZip = value 
     shipCity = GetCityAndState.CityLookup(_shipZip) 
     shipState = GetCityAndState.StateLookup(_shipZip) 
     NotifyPropertyChanged("shipZip") 
    End Set 
End Property 

, 도시와 국가는 자동으로 업데이트됩니다.

관련 문제