Simple question how to select and activate a radiobutton via code

View: New views
3 Messages — Rating Filter:   Alert me  

Simple question how to select and activate a radiobutton via code

by jbskaggs :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

When I try and use radiobutton_click()

it performs the commands in the radiobuton_click() sub  but it does not show the radiobutton as being "depressed" or selected as if you had clicked on it with a mouse.

I have also tried radiobutton.setfocus that did not do it either.

Simply put:

when the code loads a file and the resulting variable is "male" then the form should show the radiobutton1male as being selected

if the variable reads female then radiobutton2female as being selected

But the file loads properly and the variables set properly so what am I missing to change the radiobutton?

heres code:

  IF Exist(PrThing.projectpath &/ "characters/" & ListView1.Item.text & ".txt")
    thislist = file.Load(PrThing.projectpath &/ "characters/" & ListView1.Item.text & ".txt")
    elt = Split(thislist, "^")
    ListView1.Clear
  FOR EACH sb IN elt
  c += 1
  IF c = 1 THEN TextBox1.text = sb
  IF c = 2 THEN TextBox7.text = sb
  IF c = 3 THEN gender = sb
  IF c = 4 THEN TextBox3.text = sb  
  IF c = 5 THEN TextBox4.text = sb  
  IF c = 6 THEN TextBox5.text = sb  
  IF c = 7 THEN TextBox6.text = sb  
  IF c = 8 THEN TextArea1.text = sb
  IF c = 9 THEN gifpic = sb  
  NEXT
  IF gender = "male" THEN RadioButton1male_Click
  IF gender = "female" THEN RadioButton2female_Click
ENDIF

In the following screenshot the gender is male but the radiobutton is still showing female.


Re: Simple question how to select and activate a radiobutton via code

by Rob Kudla :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Monday 23 June 2008 20:33, jbskaggs wrote:
> When I try and use radiobutton_click()
> it performs the commands in the radiobuton_click() sub  but it does
> not show the radiobutton as being "depressed" or selected as if you
> had clicked on it with a mouse.

You've got it a bit backwards.  You need to change the Value property
of the radio button, which will trigger the Click event, not the
other way around.

http://gambasdoc.org/help/comp/gb.qt/radiobutton/.click

"Raised when the user clicks on the RadioButton or if its value
changes."

Rob

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Gambas-user mailing list
Gambas-user@...
https://lists.sourceforge.net/lists/listinfo/gambas-user

Re: Simple question how to select and activate a radiobutton via code

by charlesg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

IF gender = "male" THEN RadioButton1male.value=1

rgds
LightInTheBox - Buy quality products at wholesale price