Results 1 to 4 of 4

Thread: C# event programming

  1. #1
    Comfortably Numb directhex's Avatar
    Join Date
    Jul 2003
    Location
    /dev/urandom
    Posts
    17,074
    Thanks
    228
    Thanked
    1,027 times in 678 posts
    • directhex's system
      • Motherboard:
      • Asus ROG Strix B550-I Gaming
      • CPU:
      • Ryzen 5900x
      • Memory:
      • 64GB G.Skill Trident Z RGB
      • Storage:
      • 2TB Seagate Firecuda 520
      • Graphics card(s):
      • EVGA GeForce RTX 3080 XC3 Ultra
      • PSU:
      • EVGA SuperNOVA 850W G3
      • Case:
      • NZXT H210i
      • Operating System:
      • Ubuntu 20.04, Windows 10
      • Monitor(s):
      • LG 34GN850
      • Internet:
      • FIOS

    C# event programming

    I'm mildly embarassed to ask this, but it seems neither of the somethat introductory texts I own covers it, and I'm failing to find an online tutorial that doesn't suck.

    I've got a window, which has a custom object on the left (a list of "modules", which are basically custom widgets) and a custom widget on the right (one of the custom widgets). I need to make it so that clicking on something in the left-hand list makes a change to what's being done on the right. As far as I can determine, the way to do this is with Events - the MainWindow.cs should have some method which handles changing the right-hand widget, and I need to rig up *something* that allows it to be executed when clicking something in the left-hand list.

    So. What I need is a way is for my left-hand window (an instantiation of osctool2.OSCNavigation) to fire an event that the main window (osctool2.MainWindow) can detect, in order to delete and replace the right-hand window. Note that this isn't the same as the sub-widgets firing events (I'm already acting on osctool2.OSCNavigation.OSCNavigationTreeView.Selection.Changed, and the handler for this event is what I want to trigger the new custom event)

  2. #2
    Seething Cauldron of Hatred TheAnimus's Avatar
    Join Date
    Aug 2005
    Posts
    17,168
    Thanks
    803
    Thanked
    2,152 times in 1,408 posts
    not sure i can visualise what it is your trying to do here.

    But an event is happening on the left panel (call it L) and you want to call an event on the right panel (call it R)?
    throw new ArgumentException (String, String, Exception)

  3. #3
    Comfortably Numb directhex's Avatar
    Join Date
    Jul 2003
    Location
    /dev/urandom
    Posts
    17,074
    Thanks
    228
    Thanked
    1,027 times in 678 posts
    • directhex's system
      • Motherboard:
      • Asus ROG Strix B550-I Gaming
      • CPU:
      • Ryzen 5900x
      • Memory:
      • 64GB G.Skill Trident Z RGB
      • Storage:
      • 2TB Seagate Firecuda 520
      • Graphics card(s):
      • EVGA GeForce RTX 3080 XC3 Ultra
      • PSU:
      • EVGA SuperNOVA 850W G3
      • Case:
      • NZXT H210i
      • Operating System:
      • Ubuntu 20.04, Windows 10
      • Monitor(s):
      • LG 34GN850
      • Internet:
      • FIOS
    Quote Originally Posted by TheAnimus
    not sure i can visualise what it is your trying to do here.

    But an event is happening on the left panel (call it L) and you want to call an event on the right panel (call it R)?
    i want an event happening on the L to be acted upon by the main window (the one containing L and R).

    i've never really tried to have an instantiation of an object call methods of other instantiated objects before

  4. #4
    Seething Cauldron of Hatred TheAnimus's Avatar
    Join Date
    Aug 2005
    Posts
    17,168
    Thanks
    803
    Thanked
    2,152 times in 1,408 posts
    you know you can have multipule events bound to an object?

    you can even use reflection an automatically "hook" an event that belongs to a class of a certain base type!

    when you have two objects who are peers wanting to talk to each other, its easyest to get hte parent to do it. Or you can pass a referance to the events to be called to each other object.
    throw new ArgumentException (String, String, Exception)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Slow booting XP, event ID 9, hardware problem? Please help.
    By Anders in forum Help! Quick Relief From Tech Headaches
    Replies: 2
    Last Post: 25-10-2005, 05:04 PM
  2. More on the Airsoft Event...
    By Nick in forum HEXUS News
    Replies: 0
    Last Post: 11-10-2005, 03:00 PM
  3. ABIT Fatal1ty Event This Friday - Be There!
    By Steve in forum General Discussion
    Replies: 52
    Last Post: 04-09-2004, 05:20 PM
  4. C Programming Resources
    By Anders in forum Software
    Replies: 2
    Last Post: 08-05-2004, 09:08 PM
  5. Weird Problems - Please Help!!
    By chez in forum PC Hardware and Components
    Replies: 4
    Last Post: 20-09-2003, 06:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •