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 the location of button using programming

Changing the location of button using programming

Scheduled Pinned Locked Moved C#
tutorial
4 Posts 3 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.
  • H Offline
    H Offline
    Hengy
    wrote on last edited by
    #1

    Does anyone know how to change the location of a button using programming. I'm going to use it to make "simple" and "advanced" options in my search program. Thanks Hengy I like Pie

    L 1 Reply Last reply
    0
    • H Hengy

      Does anyone know how to change the location of a button using programming. I'm going to use it to make "simple" and "advanced" options in my search program. Thanks Hengy I like Pie

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Please don't double post, your old thread is perfectly suited for this question. Anyway, here is the solution:

      Button b = new Button();
      // ...
      b.Location = new Point(10, 10);

      H 1 Reply Last reply
      0
      • L Lost User

        Please don't double post, your old thread is perfectly suited for this question. Anyway, here is the solution:

        Button b = new Button();
        // ...
        b.Location = new Point(10, 10);

        H Offline
        H Offline
        Hengy
        wrote on last edited by
        #3

        Sorry for the double post... I have another problem: when the doesn'tpick anything from a combobox, it says: System.NullReferenceException was unhandled but in my code, I put a default setting in my switch. private void button1_Click(object sender, EventArgs e) { if (checkBox1.Checked != true) { MessageBox.Show("Search"); } else { switch (comboBox1.SelectedItem.ToString()) { case ("Mininova"): string targetURL = @"http://www.mininova.org"; System.Diagnostics.Process.Start(targetURL); break; case ("TorrentSpy"): string targetURL2 = @"http://www.torrentspy.com"; System.Diagnostics.Process.Start(targetURL2); break; case ("IsoHunt"): string targetURL3 = @"http://www.isohunt.com"; System.Diagnostics.Process.Start(targetURL3); break; case ("MyBitTorrent"): string targetURL4 = @"http://www.mybittorrent.com"; System.Diagnostics.Process.Start(targetURL4); break; default: MessageBox.Show("Please select a website to search."); break; } } } any ideas? thanks for the help... I seem to be asking alot of it today!:confused: Hengy I like Pie

        R 1 Reply Last reply
        0
        • H Hengy

          Sorry for the double post... I have another problem: when the doesn'tpick anything from a combobox, it says: System.NullReferenceException was unhandled but in my code, I put a default setting in my switch. private void button1_Click(object sender, EventArgs e) { if (checkBox1.Checked != true) { MessageBox.Show("Search"); } else { switch (comboBox1.SelectedItem.ToString()) { case ("Mininova"): string targetURL = @"http://www.mininova.org"; System.Diagnostics.Process.Start(targetURL); break; case ("TorrentSpy"): string targetURL2 = @"http://www.torrentspy.com"; System.Diagnostics.Process.Start(targetURL2); break; case ("IsoHunt"): string targetURL3 = @"http://www.isohunt.com"; System.Diagnostics.Process.Start(targetURL3); break; case ("MyBitTorrent"): string targetURL4 = @"http://www.mybittorrent.com"; System.Diagnostics.Process.Start(targetURL4); break; default: MessageBox.Show("Please select a website to search."); break; } } } any ideas? thanks for the help... I seem to be asking alot of it today!:confused: Hengy I like Pie

          R Offline
          R Offline
          Rob Graham
          wrote on last edited by
          #4

          If no selection is made, then the target of the switch() statement is null - comboBox1.SelectedItem is uninitialized, so you can't call the ToString() method on it. change the if -else statement to:

          if (checkBox1.Checked != true)
          {
          ...
          }
          else if (checkBox1.SelectedItem != null)
          {
          switch (comboBox1.SelectedItem.ToString())
          {
          ....
          }
          }
          else
          {
          MessageBox.Show("Please select a website to search.");
          }

          Last modified: Sunday, June 04, 2006 6:20:40 PM --

          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