Solved

User Control with option button

Posted on 1998-04-23
11
197 Views
Last Modified: 2008-02-01
I'm creating a user control with an option button but when I add two instances of my control to a form I can select both. How can I make them exclusive?
I tried the OLE_OPTEXCLUSIVE standard data type and I make the value property the default property with no results.


Tanks in advance.
0
Comment
Question by:portuga
11 Comments
 
LVL 1

Expert Comment

by:phutson
ID: 1428090
To make an option buttons exclusive they must be in the same frame or same form. If you have the option buttons in seperate frames they will not exclude each other. With that said how is the form layed out?
0
 

Author Comment

by:portuga
ID: 1428091
I have the two controls in the same Tab.
The problem is that the option buttons don't be exclusive it they are inside a user control.
0
 
LVL 1

Expert Comment

by:phutson
ID: 1428092
Have you tried drawing a frame around them in that tab>

0
 

Author Comment

by:portuga
ID: 1428093
Yes, and I can select both anyway.
0
 
LVL 1

Expert Comment

by:phutson
ID: 1428094
I probably should have asked this first but what version of vb are you using.

0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:portuga
ID: 1428095
VB5 with SP3.
0
 
LVL 1

Expert Comment

by:phutson
ID: 1428096
First thing I have to apologize I didn't realize what user controls were. Now a crude way of doing what your asking maybe to add code to the click command (if its available) to unselect the other options in the control. Maybe someone else can offer a more realistic solution or I might still find it I'm still looking.


0
 
LVL 2

Expert Comment

by:chris_a
ID: 1428097
This might be beyond VB, I believe the groups are set up when the window (control) is created by setting the the WS_GROUP flag for the first control in each group. I would guess you need to remove it from the 2nd control, and whether it would work after creation is unsure.

It might be possible with VC to subclass the option button and modify the window creation but it all sounds more trouble than doing it in the click event.

Of course this is all theory and could be complete BS

0
 
LVL 1

Expert Comment

by:flivauda
ID: 1428098
This is very easy.  Create a new project active-x control.
Then add a frame, now add to radio buttons save your control.
add another project drop two instances of your control onto the new form then run it and you should be able to select either button on either control.

Now if your custom control is a single option button (which I dont really understand the point of) of course you will be able to select both of them at the same time.  They are completly different controls and not tied to each other at all.  Tell me more the purpose of this control and i can help you more.  If you want to have X amount of option in yur frame you can cod ethe control to do that but I don't see the value in a control that is just a radio button.
0
 

Author Comment

by:portuga
ID: 1428099
I realy want to make a user control with a single option button, because I want add some properties.
0
 
LVL 5

Accepted Solution

by:
bin_huwairib earned 30 total points
ID: 1428100
portuga,

Add option button (option1) to a user control (usercontrol1) then paste the following code in the UserControl1:

Sub ResetOptionButton()
 Option1.Value = False
End Sub

Private Sub Option1_Click()
 Dim MyControl As Control

 With UserControl.Parent
  For Each MyControl In .Controls
   If TypeOf MyControl Is UserControl1 Then
    If UCase(MyControl.Name) <> UCase(UserControl.Parent.ActiveControl.Name) Then
     Call MyControl.ResetOptionButton
    End If
   End If
  Next
 End With
End Sub


Best Regards
Bin Huwairib
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Mysql vs Oracle 10 120
Access 2016 VB code 9 86
VB6 - Convert HH:MM into Decimal 8 38
How to make an ADE file by code? 11 42
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now