Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a UserControl that holds several sets of RadioButtons.

Now I don't want the UserControl to set the RadioButtons. How can I turn this feature off?

 

I don't want to put the different set's of RB's into multiple panels because I will end up having lot's of extra (useless) controls. Instead I'm handling the setting and resetting of RB's myself + drawing a few lines in order to seperate the RB's visually - No I don't want to use a groupBox as it would make a bad situation worse.

 

THX

Debug me...
Posted (edited)

Okay ... had to derive from RadioButton and overwrite MouseDown to prevent that feature ... but when I set the Checked property manually the control resets the other rb's again :(

 

I can't override the Checked property either so I guess I'll have to draw the black dot myself ... a lot of work just because I can't set a property :mad:

 

Can someone tell me how to immitate that little check? I tried DrawPie but it's not giving me a perfect circle.

Edited by Malfunction
Debug me...
  • *Experts*
Posted

Your radio buttons MUST be grouped in some kind of containing control or else they will not work like radio buttons. There is no programmatic way (that I've ever seen) to group them without having them inside a control.

 

If you don't want the containing control to be visible then try a panel. It's default border is none and won't show up.

 

Unless you have something very simple like 2 or maybe 3 radio buttons, keeping them grouped visually in something like a groupbox is definitely the way to go. If you only have 2 radio buttons, try a checkbox instead?

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

Okay here's what I'm doing:

I'm creating Templates of different types to be used on digital questionaires.

Each row represents an item containing a textbox and multiple radiobuttons (number depending on the scale).

So when you create a template containing 20 Items with a scale of 9 you end up with 20 Textboxes and 180 RadioButtons.

I was looking for several datagrids to accomplish this task but none of them suited my demands (they either lacked technical or visual features).

 

That's why I started to code the templates from scratch. First I was using UserControls. The template was a user control holding items which held the radioButtons. Since the items where userControls, too I didn't have to bother about the radioButtons the items handled them automatically.

However since all rows and columns needed to be resized dynamically a lot of controls needed to be resized and repositioned at the same time. The performance of my template was too bad.

The new approach is to only have one userControl (the template) which holds the textboxes and radiobuttons directly. It has a two dimensional array to organize the contained controls. That requires more thinking than the previous approach but it's much faster and requires less objects to be created.

Since all readioButtons are contained in one userControl I had the problem with automatic resetting of all other radioButtons.

The workaround is quite simple:

I inherit the frameworks radioButton.

I override the mouseUp and MouseDown event inside the RadionButton to prevent the radioButton of sending it's events to the userControl - nothing is set automatically anymore.

I added my own Checked property and draw the check myself. The template can reset the other radiobuttons by looking into the array to set only those radiobuttons which are in the same row.

The only thing I haven't managed is to draw a circle that looks exactly like the check of the original radioButton.

Debug me...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...