Comparing a control with another control's parent

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark Denardo

    #1

    Comparing a control with another control's parent

    Hi I have an app that has a number of textboxes (richtextboxes to be exact)
    that get created dynamically and I add a few at a time to panel controls (so
    I can flip a group in and out when I want). So the textbox objects get
    added to the panel object like so:

    panelObj.Contro ls.Add(textboxO bj)

    And then I store the panel Objects in a linked list so I can sort through
    them later.

    Each texbox I create I setup a Handler to trap any time a user leaves the
    box like so:


    AddHandler tb.Leave, AddressOf CellEvent_Leave


    My CellEvent_Leave method looks like so:
    Private Sub CellEvent_Leave (ByVal sender As Object, ByVal e As
    System.EventArg s)

    As I traverse the linked list, I am comparing the Panel Objects I stored
    with the sender of the event's parent like so:

    If (panelObj Is sender.parent) Then

    But this is never evaluating to true, even though I can trace both panelObj
    and sender.parent and see I'm looking at the same objects.

    I'm thinking this may be some sort of pointer issue. Perhaps there is a
    copy being made somewhere. Should I be comparing these in a different way,
    or is something wrong in what I'm trying to do. Is there a better way to
    trap events on dynamically created controls like I'm doing?






  • Chris

    #2
    Re: Comparing a control with another control's parent

    Mark Denardo wrote:[color=blue]
    > Hi I have an app that has a number of textboxes (richtextboxes to be exact)
    > that get created dynamically and I add a few at a time to panel controls (so
    > I can flip a group in and out when I want). So the textbox objects get
    > added to the panel object like so:
    >
    > panelObj.Contro ls.Add(textboxO bj)
    >
    > And then I store the panel Objects in a linked list so I can sort through
    > them later.
    >
    > Each texbox I create I setup a Handler to trap any time a user leaves the
    > box like so:
    >
    >
    > AddHandler tb.Leave, AddressOf CellEvent_Leave
    >
    >
    > My CellEvent_Leave method looks like so:
    > Private Sub CellEvent_Leave (ByVal sender As Object, ByVal e As
    > System.EventArg s)
    >
    > As I traverse the linked list, I am comparing the Panel Objects I stored
    > with the sender of the event's parent like so:
    >
    > If (panelObj Is sender.parent) Then
    >
    > But this is never evaluating to true, even though I can trace both panelObj
    > and sender.parent and see I'm looking at the same objects.
    >
    > I'm thinking this may be some sort of pointer issue. Perhaps there is a
    > copy being made somewhere. Should I be comparing these in a different way,
    > or is something wrong in what I'm trying to do. Is there a better way to
    > trap events on dynamically created controls like I'm doing?
    >
    >
    >
    >
    >
    >[/color]

    I'm a bit confused on why you are storing the link list?

    Sender.Parent will tell you what panel it is on. Sender.Parent.C ontrols
    will give you all the controls that are in that panel.

    Chris

    Comment

    • Mark Denardo

      #3
      Re: Comparing a control with another control's parent

      Okay disregard this message. I had another layer of controls (TabPages)
      that the panels were sitting on, that were very similar (including text)
      that I had mistakenly flip flopped and thus they were not the same. I
      corrected the problem and they compare like I was hoping.

      Chris to answer your question, the panels themselves weren't a link list,
      but class objects were being link listed together - that contain a bunch of
      information on each panel plus a pointer to the panel object itself. Plus
      each object is related to the object before and after it, so I need to keep
      them in order. If I could somehow store a pointer to my class objects in
      the panel object it would make my life easier when doing a lookup of the
      class information related to the panel object.




      "Chris" <no@spam.com> wrote in message
      news:ej3mM3$kFH A.2472@TK2MSFTN GP15.phx.gbl...[color=blue]
      > Mark Denardo wrote:[color=green]
      >> Hi I have an app that has a number of textboxes (richtextboxes to be
      >> exact) that get created dynamically and I add a few at a time to panel
      >> controls (so I can flip a group in and out when I want). So the textbox
      >> objects get added to the panel object like so:
      >>
      >> panelObj.Contro ls.Add(textboxO bj)
      >>
      >> And then I store the panel Objects in a linked list so I can sort through
      >> them later.
      >>
      >> Each texbox I create I setup a Handler to trap any time a user leaves the
      >> box like so:
      >>
      >>
      >> AddHandler tb.Leave, AddressOf CellEvent_Leave
      >>
      >>
      >> My CellEvent_Leave method looks like so:
      >> Private Sub CellEvent_Leave (ByVal sender As Object, ByVal e As
      >> System.EventArg s)
      >>
      >> As I traverse the linked list, I am comparing the Panel Objects I stored
      >> with the sender of the event's parent like so:
      >>
      >> If (panelObj Is sender.parent) Then
      >>
      >> But this is never evaluating to true, even though I can trace both
      >> panelObj and sender.parent and see I'm looking at the same objects.
      >>
      >> I'm thinking this may be some sort of pointer issue. Perhaps there is a
      >> copy being made somewhere. Should I be comparing these in a different
      >> way, or is something wrong in what I'm trying to do. Is there a better
      >> way to trap events on dynamically created controls like I'm doing?
      >>
      >>
      >>
      >>
      >>
      >>[/color]
      >
      > I'm a bit confused on why you are storing the link list?
      >
      > Sender.Parent will tell you what panel it is on. Sender.Parent.C ontrols
      > will give you all the controls that are in that panel.
      >
      > Chris[/color]


      Comment

      • Cor Ligthert [MVP]

        #4
        Re: Comparing a control with another control's parent

        Mark,

        A little simple advice, try to set in top of your program or in your options

        Option Strict On

        That will probably help you a lot with this kind of questions.

        Cor


        Comment

        Working...