Home Forums WPF controls Xceed DataGrid for WPF How to say to refresh data

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #24579 |

    Hi!
    How to say to the DataGrid that a field value was changed and the DataGrid should show the new value.

    Imported from legacy forums. Posted by Sergey (had 465 views)

    User (Old forums)
    Member
    Post count: 23064

    you may use the UpdateLayout function

    Imported from legacy forums. Posted by serhio (had 404 views)

    Xceed Support
    Member
    Post count: 5658

    To ensure that the Cell for the object’s field get refreshed, your data object has to implement either INotifyPropertyChanged, derive from DependencyObject (and property must be a DependencyProperty) OR the data source must implement IBindingList (and a ListChanged event [ action type ItemChanged] must be raised when the item changes ).

    Imported from legacy forums. Posted by Marcus [Xceed] (had 273 views)

    User (Old forums)
    Member
    Post count: 23064

    That’s great! But it’s does’t works!

    Me data class is:

    <i>
    Imports System.ComponentModel

    Namespace Client.Models

    <b>
    Public Class InitialPackagesInformation
    </b>
    Implements ComponentModel.INotifyPropertyChanged

    Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

    Private DefaultOrderField As Integer
    Public Property DefaultOrder() As Integer
    Get
    Return Me.DefaultOrderField
    End Get
    Set(ByVal value As Integer)
    Me.DefaultOrderField = value
    End Set
    End Property

    Private IsInNormField As Boolean
    Public Property IsInNorm() As Boolean
    Get
    Return IsInNormField
    End Get
    Set(ByVal value As Boolean)
    IsInNormField = value
    End Set
    End Property

    Private DiscrepencyField As Decimal
    Public Property Discrepency() As Decimal
    Get
    Return DiscrepencyField
    End Get
    Set(ByVal value As Decimal)
    If value <> DiscrepencyField Then
    DiscrepencyField = value
    NotifyEvent(“Discrepency”)
    End If

    End Set
    End Property

    Private WeightByFactField As Decimal
    Public Property WeightByFact() As Decimal
    Get
    Return WeightByFactField
    End Get
    Set(ByVal value As Decimal)
    If value <> WeightByFactField Then
    Discrepency = WeightByLabelField – value
    WeightByFactField = value
    NotifyEvent(“WeightByFact”)
    End If
    End Set
    End Property

    Private ResultWeightField As Decimal
    Public Property ResultWeight() As Decimal
    Get
    Return ResultWeightField
    End Get
    Set(ByVal value As Decimal)
    If value <> ResultWeightField Then
    ResultWeightField = value
    NotifyEvent(“ResultWeight”)
    End If
    End Set
    End Property

    Private WeightByLabelField As Decimal
    Property WeightByLabel() As Decimal
    Get
    Return WeightByLabelField
    End Get
    Set(ByVal value As Decimal)
    If value <> WeightByLabelField Then
    WeightByLabelField = value
    NotifyEvent(“WeightByLabel”)
    End If
    End Set
    End Property

    Public Sub NotifyEvent(ByVal fieldName As String)
    RaiseEvent PropertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(fieldname))
    End Sub
    <b>
    End Class
    </b>

    End Namespace
    </i>

    My DataContext class is:
    <i>
    Namespace Client.Models
    <b>
    Public Class InitialPackagesDescription
    </b>
    Private SelectedPackageField As InitialPackagesInformation
    Public Property SelectedPackage() As InitialPackagesInformation
    Get
    Return SelectedPackageField
    End Get
    Set(ByVal value As InitialPackagesInformation)
    SelectedPackageField = value
    End Set
    End Property

    <b>
    Private PackagesListField As BindingList(Of InitialPackagesInformation)
    Public Property PackagesList() As BindingList(Of InitialPackagesInformation)
    Get
    Return PackagesListField
    End Get
    Set(ByVal value As BindingList(Of InitialPackagesInformation))
    PackagesListField = value
    End Set
    End Property
    </b>

    Private IsReadOnlyField As Boolean
    Public Property IsReadOnly() As Boolean
    Get
    Return IsReadOnlyField
    End Get
    Set(ByVal value As Boolean)
    IsReadOnlyField = value
    End Set
    End Property

    End Class

    End Namespace
    </i>

    Inside xaml.vb partial class:
    <i>
    Public Sub Oninit(ByVal description As Client.Models.InitialPackagesDescription)
    Dim sortDescription As System.ComponentModel.SortDescriptionCollection

    source = New System.Windows.Forms.BindingSource
    source.DataSource = description
    Me.DataContext = source
    ‘ AddHandler description.ListChanged, AddressOf OnListChanged

    <b>
    <i>
    ‘It’s does’t works for BindingList
    </i>
    sortDescription = WeightInitialGrid.Items.SortDescriptions
    sortDescription.Clear()
    sortDescription.Add(New System.ComponentModel.SortDescription(“DefaultOrder”, ComponentModel.ListSortDirection.Ascending))
    </b>
    End Sub

    Public Sub OnListChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ListChangedEventArgs)
    RaiseEvent PropertyChanged(sender, New System.ComponentModel.PropertyChangedEventArgs(e.PropertyDescriptor.DisplayName))
    <b>
    ‘Does’t take effect if uncomment AddHandler description.ListChanged above
    WeightInitialGrid.UpdateLayout()
    </b>

    End Sub

    </i>
    SDJXCEED@2008

    Imported from legacy forums. Posted by Sergey (had 753 views)

    Xceed Support
    Member
    Post count: 5658

    Could you tell me exactly what version you have?

    I’ve looked in our bug database and found some issues like the one you are experiencing that were fixed in version 1.1.7326. If you are using a version anterior to that one, then I suggest updating to “at least” 1.1.7326 ( package version 3.0.7326.14130, June 27th 2007 ).

    Imported from legacy forums. Posted by Marcus [Xceed] (had 4138 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.