Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Optiongroup caption is coming up blank

  1. #1

    Optiongroup caption is coming up blank

    Hi,

    I am able to reference my optiongroup and get the correct value, but the caption is coming up as blank.

    This is in a custom gadget.


    Code:
    optgrp = createobject("optiongroup")
    	optgrp.buttoncount = 8
    	
    	optgrp.buttons(1).caption ="Change Request - Existing process"
    	optgrp.buttons(2).caption ="Change request - New Process "
    	optgrp.buttons(3).caption ="Deadlock Occurence"
    	optgrp.buttons(4).caption ="Inadequate Capacity"
    	optgrp.buttons(5).caption ="alerts/events exceeding defined threshold"
    	optgrp.buttons(6).caption ="Change RollBack"
    	optgrp.buttons(7).caption ="Urgent/ Emergency Change"
    	optgrp.buttons(8).caption ="Software upgrade"
    	optgrp.value = 1
    	
    	gadget1.addobject(optgrp)

  2. #2
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,841
    Hi Herb,

    Do you mean you can't see the captions, or?

    I pasted your code into a gadget and it seemed to display correctly. Do you get any output in the Console error window?

    Name:  optiongroup.png
Views: 322
Size:  19.0 KB

  3. #3
    Sorry - I was not clear.

    If I want to programmatically get the caption of the selected option, the value for caption is blank.
    Meaning - If I did m.val = optgrp.value, the value of m.val would equal 1 (or whatever Item was chosen).
    If I did m.caption = optgrp.caption, the value is always a blank string.

    Herb

  4. #4
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,184
    Hi Yvonne,

    I added a form section, added a VFP custom gadget, and then uncommented the gadget code at the bottom.

    Nothing happens, in dev mode and when pressing Run from dev mode.

    Should it work?

    thanks,

    Hank

  5. #5
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,841
    Hi Herb,

    The optiongroup.caption is the text displayed in the Frame. You need to get the caption for the selected button:

    m.caption = optgrp.buttons(optgrp.value).caption

    Yvonne

  6. #6
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,841
    Hi Hank,

    Yes - worked for me

    Anything in the Console error window?

    Yvonne

  7. #7
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,184
    Quote Originally Posted by yvonne.milne View Post
    Hi Hank,

    Yes - worked for me

    Anything in the Console error window?

    Yvonne
    Yes, and after I fixed that, the default example worked. Thanks!

    To get Herb's working, I had to add a line

    Code:
    gadget1 = createobject("gadget1")
    before the addobject line; and had to add

    Code:
    return gadget1
    to the end of the code he supplied.

    thanks,

    Hank
    Last edited by HankFay; 2013-05-08 at 13:46. Reason: corrected code

  8. #8
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,184
    Hi Yvonne,

    ps: in the generated code for a gadget, there is a procedure watch() which doesn't appear in the Wiki, at least any place I can find. Any information appreciated.

    thanks,

    Hank

  9. #9
    Hi Hank, Yvonne,

    Just to be clear, when I reference my optiongroup, I can get the value of the selected item.

    ie - m.val = optgrp.value.

    What I am trying to get is the caption of the selected Item. Something like m.Caption = optgrp.caption. This is what is coming back as a blank string.

    Thanks.

    Herb

  10. #10
    I may have clouded the issue by not being clear. I can see my optiongroup, I just cant get the selected caption.

    define class btnSubmit as commandbutton
    proc click()
    =messagebox("Selected Value =:"+alltrim(str(optgrp.value))+" Selected Caption =:"+optgrp.caption)
    endproc

    enddefine

    This is what I get. I get the selected value, but not the selected caption.Name:  optionGroup.jpg
Views: 161
Size:  50.9 KB

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us