CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 4 1234 LastLast
Results 1 to 15 of 46
  1. #1
    Join Date
    Mar 2009
    Posts
    118

    [RESOLVED] help about option buttons

    please help me about option buttons [radio buttons] ..i want to put two frames on a form and two radio buttons each linked to one frame and other ... and how to make each frame equally in size on form ..

    thanks in advance

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: help about option buttons

    Set the size of the frames the same either by dragging them out to the same size or by setting the height and width properties.

  3. #3
    Join Date
    Mar 2009
    Posts
    118

    Re: help about option buttons

    Quote Originally Posted by DataMiser View Post
    Set the size of the frames the same either by dragging them out to the same size or by setting the height and width properties.

    but sir, you left the main question that how options buttons can be linked to frames
    code please

  4. #4
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,900

    Re: help about option buttons

    Just drop the Option Buttons inside the frame and they automatically work - there is no special "linking" or programming required

  5. #5
    Join Date
    Mar 2009
    Posts
    118

    Re: help about option buttons

    Quote Originally Posted by George1111 View Post
    Just drop the Option Buttons inside the frame and they automatically work - there is no special "linking" or programming required

    sir, again ur answer is confussing me ... my project details

    i have a form on one side of it .. i am putting suppose three frames with diffrent data on each frame and on the other side of form i have three radio buttons ...

    suppose we give the name to radio button [ optionbtn1, optionbn2 and optionbtn2]

    same for frames [ frmA, frmB and frmC]

    i want when an option button 1 is clicked frmA should be visible on form while runtime and same procedure for other two

    please provide the code

  6. #6
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: help about option buttons

    I think mahii wants the option button to select either frame. (Just guessing )

    The easiest way to do so is to have your frames organized as an array.
    Your option buttons are an array automatically if they have the same name.
    Look into the Index property if there is 0 in one and 1 in the other, you have an array.
    Now to the frames. Give them both the same name and you will be asked if you want an arry.
    Say yes to that. Then control the Index properties if they are 0 and 1 too.
    One or other way I assume that both frames will have the same size and occupy the same space.
    Now comes the linking. In the click event of the OptionButton goes this code:
    Code:
    Private Sub Option1_Click(Index As Integer)
      Frame1(Index).Visible = True
      Frame1(Index).ZOrder 0
    End Sub
    Either Option button will bring its Frame to the foreground and make it visible.
    Linking has been achieved by using the Index parameter which indicates which one of the option buttons was clicked.

    Have to add: Neither of the OptionButtons must reside in one of the frames then.

    You should examine the SSTab control which pretty much does all that stuff automatically.
    Maybe that's what you want.

  7. #7
    Join Date
    Mar 2009
    Posts
    118

    Re: help about option buttons

    Quote Originally Posted by WoF View Post
    I think mahii wants the option button to select either frame. (Just guessing )

    The easiest way to do so is to have your frames organized as an array.
    Your option buttons are an array automatically if they have the same name.
    Look into the Index property if there is 0 in one and 1 in the other, you have an array.
    Now to the frames. Give them both the same name and you will be asked if you want an arry.
    Say yes to that. Then control the Index properties if they are 0 and 1 too.
    One or other way I assume that both frames will have the same size and occupy the same space.
    Now comes the linking. In the click event of the OptionButton goes this code:
    Code:
    Private Sub Option1_Click(Index As Integer)
      Frame1(Index).Visible = True
      Frame1(Index).ZOrder 0
    End Sub
    Either Option button will bring its Frame to the foreground and make it visible.
    Linking has been achieved by using the Index parameter which indicates which one of the option buttons was clicked

    Have to add: Neither of the OptionButtons must reside in one of the frames then.

    You should examine the SSTab control which pretty much does all that stuff automatically.
    Maybe that's what you want.
    No sir i did not get properly ... tell me whole procedures of Array ... how to achives these

  8. #8
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: help about option buttons

    Code:
    Dim Frame1(6) as Frame
    will create 7 Frames (0-6)

    You can also REDIM() if the count were to change
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  9. #9
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: help about option buttons

    Well, this would be a programmatical way of doing it.

    The way you make arrays at design time is, you drag a frame to your form.
    Then you size and place it.
    Then you might copy it (right click and copy) and paste (right click to form and paste) it again.
    You will be asked if you want an array and simply have to say yes.

    The other way of doing it during design, you drag another frame to your form.
    It will automatically get named Frame2, if you had Frame1 before.
    Now you select Frame2 and change its Name property to Frame1.
    Again you will be asked if you want an array and you simply have to say Yes.

    You have to understand, that an array of Frames is addressed by their index.
    It is like a running number.
    If you have 3 Frames, they might likely be addressed as Frame1(0), Frame1(1) and Frame1(2).
    That's how elements of an array are addressed.
    The Index is a property you can also determine in the property sheet of an object.

    The above applies to all types of controls.

  10. #10
    Join Date
    Mar 2009
    Posts
    118

    Re: help about option buttons

    Quote Originally Posted by WoF View Post
    Well, this would be a programmatical way of doing it.

    The way you make arrays at design time is, you drag a frame to your form.
    Then you size and place it.
    Then you might copy it (right click and copy) and paste (right click to form and paste) it again.
    You will be asked if you want an array and simply have to say yes.

    The other way of doing it during design, you drag another frame to your form.
    It will automatically get named Frame2, if you had Frame1 before.
    Now you select Frame2 and change its Name property to Frame1.
    Again you will be asked if you want an array and you simply have to say Yes.

    You have to understand, that an array of Frames is addressed by their index.
    It is like a running number.
    If you have 3 Frames, they might likely be addressed as Frame1(0), Frame1(1) and Frame1(2).
    That's how elements of an array are addressed.
    The Index is a property you can also determine in the property sheet of an object.

    The above applies to all types of controls.
    thanks sir i got it ... thanks for right guidence ... but two problem is there i want fram1(0) should be an itroductuion page and should not be connected to any option button ... number 2nd i have lot of option buttons which are not possible to put on one form i want that other page should be created within the form so that all the option buttons could be adjusted ... help further please

  11. #11
    Join Date
    Mar 2009
    Posts
    118

    Re: help about option buttons

    please help me

  12. #12
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: help about option buttons

    If you do not want 1 or more frames included then do not make them part of the array. In other words just drag another frame onto the form which will have a different name by default and not be part of yoru array. Of course you must handle it seperately through code.

    As for the number of options e.g. radio buttons. You can always use an additional group of frames to hold those as well, just need to add one or two in each frame to move next<>back. Same idea as before toggle the visibility of the frame in question.

    That said if you are trying to place this many controls onto a single form you may run into an issue at some point. I often use 4-8 frames on Mobile apps but rarely on the pc.

    Someone else suggested the use of a tab control instead but I see no response to that idea on your part. You may find this is a better solution for you. Also you may want to consider using more than one form.

  13. #13
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: help about option buttons

    First thing, I'd study the SSTab-control which is very versatile and takes a lot of programming away from its user.

    Other consideration, DataMiser gave, is to take out your primary frame of your array and give it an individual name for individual proceedings.

    To group OptionButtons you would have to use a frame, I think. You can use lot's of frames with the only purpose to group a set of option buttons. Just put them in an array, set the Border property to 0 and they are not visible at all in your app, but they group your OptionButtons as if they were Radio-buttons. (If you know what I mean).

  14. #14
    Join Date
    Mar 2009
    Posts
    118

    Re: help about option buttons

    i think my brothers did not get me properly ... i mean when we get option buttons and frames into an array ... then whenever we open the project at runtime there is always ist option button selected and ist frame visible.. i want that at runtime optionbutton 1 should not be highlighted and frame 1 should be visible as an introduction of the project.. it means at runtime let the user chose which option button should be selected as per their desire ..

  15. #15
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: help about option buttons

    You can save the settings in many ways. A file, a db, or in the registry (not recommended)
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Page 1 of 4 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured