For Each??? Questions

Dim rNode As Infragistics.Win.UltraWinTree.UltraTreeNode

For Each rNode In UltRepairCodes.Nodes

If e.KeyCode = Keys.Enter Then rNode.CheckedState = CheckState.Checked

Next

I just want to access one element and if i hit enter it will check but i am getting them all checked...I know i am saying "for each" node in the list but i just want it to be one item in the list to be checked when i hit enter....what should i do a lil lost!




Answer this question

For Each??? Questions

  • Vincent Josset

    Select Node I see a selected property ....elaborrate a lil more for me DMan1

  • Jeff Ulrich

    use the afterselect event or you can use the selectednode property....



  • lorijean44

    Private Sub UltRepairCodes_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles UltRepairCodes.KeyDown

    Dim rNode As Infragistics.Win.UltraWinTree.UltraTreeNode

    If e.KeyCode = Keys.Enter Then rNode.Selected = CheckState.Checked

    End Sub

    This is the exception i get....

    An unhandled exception of type 'System.NullReferenceException' occurred in Tracker.exe

    Additional information: Object reference not set to an instance of an object.



  • ChrisTullier

    I'm not fimiliar with the infragistics treeview control, however the VS version has a selectednode method that retrieves a reference to the currently selected node on the tree....it also has an event "afterselect" in which the event arguments contains a reference to the selected node..

  • Chad Bumstead

    Thanks i actually got it to work doing it like so.......

    Dim rNode As Infragistics.Win.UltraWinTree.UltraTreeNode

    For Each rNode In UltRepairCodes.SelectedNodes

    If e.KeyCode = Keys.Enter Then rNode.CheckedState = CheckState.Checked

    Next



  • David Pinero

    The Infragistics controls are all extensions of the base controls for the most part so they have pretty much all of the same properties and methods. 

    The reason you're getting the error is you are declaring rNode but you're not setting to anything before you try to change a property.  Try something like this, get rid of rNode altogether:

    if e.KeyCode = Keys.Enter And sender.ActiveNode IsNot Nothing Then
       sender.ActiveNode.CheckedState = CheckState.Checked
    End If


  • For Each??? Questions