Raising Events on Editable Root Collections?Raising Events on Editable Root Collections?
Old forum URL: forums.lhotka.net/forums/t/1031.aspx
brembot posted on Friday, August 25, 2006
Is anyone know this? My objective here is to control the Enable Property of the Save Button. I want my Editable Root Collections to control the Enable Property of my Save Button. For example: If the collections is Dirty And Valid then the Save Button is enabled otherwise disabled. My is question is how am i going to implement this one? Before, we use application.Idle event to check if the collections is Savable but the problem with that event is everytime you move the mouse, it will execute.
Thanks
RockfordLhotka replied on Sunday, August 27, 2006
You can handle the ListChanged event to know any time that the collection or its contents are changed.
brembot replied on Monday, August 28, 2006
Thanks Rocky for your response. I found the solution on how to solve my problem. I hope this could help to everybody. Here's what i've done.
Code:
Private WithEvents mBSRoots As New BindingSource
Private mRoots As EditableRootList = EditableRootList.NewEditableRootList
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' fetching of data
mRoots = EditableRootList.GetEditableRootList()
' set the bidingsource
mBSRoots.DataSource = mRoots
' bind the controls
Me.txtName.DataBindings.Add("Text", mBSRoots, "Name", False, DataSourceUpdateMode.OnPropertyChanged)
' event listener
AddHandler mBSRoots.CurrentItemChanged, AddressOf IsSavable
End Sub
Private Sub IsSavable(ByVal sender As Object, ByVal e As EventArgs)
Me.cmdIsSavable.Enabled = mRoots.IsSavable
End Sub
Copyright (c) Marimer LLC