Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Changing all cursor types on a form

Changing all cursor types on a form

Scheduled Pinned Locked Moved C#
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fracalifa
    wrote on last edited by
    #1

    Hello everybody, I want to change the cursors over all input controls (textboxes) on a form in a loop. I tried something like: foreach(TextBox tb in formclassname) // but instead of a class a var is expected { tb.Cursor = Cursors.No; // change cursor of textboxes } What's the right code to make the expected operation ? Thank you in advance Frank -- modified at 11:45 Thursday 15th December, 2005

    P 1 Reply Last reply
    0
    • F fracalifa

      Hello everybody, I want to change the cursors over all input controls (textboxes) on a form in a loop. I tried something like: foreach(TextBox tb in formclassname) // but instead of a class a var is expected { tb.Cursor = Cursors.No; // change cursor of textboxes } What's the right code to make the expected operation ? Thank you in advance Frank -- modified at 11:45 Thursday 15th December, 2005

      P Offline
      P Offline
      Polis Pilavas
      wrote on last edited by
      #2

      Assuming you are trying to change the cursors from within the form that the textboxes are on, you can try something like this:

      foreach (Control tmp in this.Controls)
      if (tmp is TextBox)
      tmp.Cursor = Cursors.Hand;

      Or like this:

      foreach (Control tmp in this.Controls)
      if (tmp.GetType().Name == "TextBox")
      tmp.Cursor = Cursors.Hand;

      Regards, Polis Can you practice what you teach?

      F 1 Reply Last reply
      0
      • P Polis Pilavas

        Assuming you are trying to change the cursors from within the form that the textboxes are on, you can try something like this:

        foreach (Control tmp in this.Controls)
        if (tmp is TextBox)
        tmp.Cursor = Cursors.Hand;

        Or like this:

        foreach (Control tmp in this.Controls)
        if (tmp.GetType().Name == "TextBox")
        tmp.Cursor = Cursors.Hand;

        Regards, Polis Can you practice what you teach?

        F Offline
        F Offline
        fracalifa
        wrote on last edited by
        #3

        Thank's that's what I'm looking for. Frank

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups