Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

User Control with option button

Posted on 1998-04-23
11
Medium Priority
?
214 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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
 

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 60 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 Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

636 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