4 Replies - 1152 Views - Last Post: 10 October 2012 - 07:41 PM Rate Topic: -----

#1 xilith117  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 70
  • Joined: 13-August 11

making a radio button programatically

Posted 10 October 2012 - 02:28 PM

OK, here is what I have:
Dim radio As New RadioButton

        With radio
            .Location.X.Equals(100)
            .Location.Y.Equals(100)
            .Text = ""
        End With


I want a text-less radio button at 100,100 what did I do wrong? Thanks.

This post has been edited by xilith117: 10 October 2012 - 02:29 PM

Is This A Good Question/Topic? 0
  • +

Replies To: making a radio button programatically

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9208
  • View blog
  • Posts: 34,589
  • Joined: 12-June 08

Re: making a radio button programatically

Posted 10 October 2012 - 02:48 PM

You are not setting the x and y coordinates you are asking to evaluate if they equal those numbers.

Also where are you adding the radiobutton to the my.controls?
Was This Post Helpful? 0
  • +
  • -

#3 xilith117  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 70
  • Joined: 13-August 11

Re: making a radio button programatically

Posted 10 October 2012 - 03:52 PM

I had a feeling it was just checking the X and Y not setting them...How do I fix it?

Quote

Also where are you adding the radiobutton to the my.controls?


Nowhere?

This post has been edited by xilith117: 10 October 2012 - 03:53 PM

Was This Post Helpful? 0
  • +
  • -

#4 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: making a radio button programatically

Posted 10 October 2012 - 04:38 PM

use the = operator. The location points call for a integer value so set x = 100 and y = 100

Don't forget to add the control to the forms controls collection as modi123_1 hinted.
Was This Post Helpful? 0
  • +
  • -

#5 lerning  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 50
  • Joined: 08-August 09

Re: making a radio button programatically

Posted 10 October 2012 - 07:41 PM

View Postxilith117, on 10 October 2012 - 03:28 PM, said:

OK, here is what I have:
Dim radio As New RadioButton

        With radio
            .Location.X.Equals(100)
            .Location.Y.Equals(100)
            .Text = ""
        End With


I want a text-less radio button at 100,100 what did I do wrong? Thanks.


Your on the right track, but you need to specifiy a 'New' location for the button by using '.Location = New System.Drawing.Point(100, 100)' and then telling the form to draw it on the screen using 'Me.Controls.Add(radButton)'

Dim radButton As New RadioButton

        With radButton
            .Checked = False
            .Text = "Radio Button"
            .Location = New System.Drawing.Point(100, 100)
            Me.Controls.Add(radButton)
        End With

        Dim radButton2 As New RadioButton

        With radButton2
            .Checked = True
            .Text = "Radio Button 2"
            .Location = New System.Drawing.Point(210, 100)
            Me.Controls.Add(radButton2)
        End With



Here is a screenshot for what the error shows, if you are using visual studio, placing your mouse over the squiggly blue line will give you your answer:

http://s7.postimage..../correction.png

or the error below will tell you: Error 1 Value of type 'String' cannot be converted to 'System.Drawing.Point'. Thus meaning you must create a 'New' point using 'New System.Drawing.Point(#,#)' Your compiler will give you an error but the error usually implies its the answer as well.

This post has been edited by lerning: 10 October 2012 - 07:50 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1