vba 制作独立的选项按钮组
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17752045/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Making independent groups of option buttons
提问by user2385809
I am looking to make sort of a little form with groups of checkboxes and option buttons which will later feed a vba code. I need to make group boxes with 3 option boxes in them but independent. As it is now i press one of the options bokes and it inchecks an option box in the other group. They are all connected and i don't want this. Any Ideas? Thanks
我正在寻找一种带有复选框和选项按钮组的小表单,稍后将提供 vba 代码。我需要制作包含 3 个选项框但独立的组框。就像现在一样,我按下其中一个选项 bokes,它会选中另一组中的选项框。他们都是相连的,我不想要这个。有任何想法吗?谢谢
采纳答案by Ben Van Dyke
You need to enclose each group of option buttons in a Group Box control. You can access this from the same menu you used to add the buttons.
您需要将每组选项按钮包含在一个 Group Box 控件中。您可以从用于添加按钮的相同菜单中访问它。
See this link for more info: http://office.microsoft.com/en-us/excel-help/add-a-group-box-or-frame-control-to-a-worksheet-HP010236679.aspx.
有关详细信息,请参阅此链接:http: //office.microsoft.com/en-us/excel-help/add-a-group-box-or-frame-control-to-a-worksheet-HP010236679.aspx。
回答by Nixz
A simple way to do is to set the GroupName property for the option buttons in the form. Set it to OB1 for first three option buttons and OB2 for the next three option buttons. Now they will work as two groups and you can check one each from eithr groups.
一个简单的方法是为表单中的选项按钮设置 GroupName 属性。对于前三个选项按钮,将其设置为 OB1,对于接下来的三个选项按钮,将其设置为 OB2。现在他们将作为两组工作,您可以从 eihr 组中各检查一个。
回答by Laurie 01886
I agree with Nixz's response and would like to add more detail. Nixz posted: A simple way to do is to set the GroupName property for the option buttons in the form. Set it to OB1 for first three option buttons and OB2 for the next three option buttons. Now they will work as two groups and you can check one each from eithr groups.
我同意 Nixz 的回应,并想添加更多细节。Nixz 发表:一个简单的方法是为表单中的选项按钮设置 GroupName 属性。对于前三个选项按钮,将其设置为 OB1,对于接下来的三个选项按钮,将其设置为 OB2。现在他们将作为两个组工作,您可以从 eihr 组中各检查一个。
To make this work for me, I edited the GroupName in Properties for each radio button selection. For one group, I edited the two selections' GroupName(s) and called them each Question2. For the second set, I edited the GroupName for each radio button choice, calling them both Question5. This told excel they were grouped, even though they were in a Group Box, eXcel was not recognizing them as in separate Group Boxes. Hope this helps!
为了使这个对我有用,我在属性中为每个单选按钮选择编辑了 GroupName。对于一个组,我编辑了两个选择的 GroupName(s) 并将它们分别称为 Question2。对于第二组,我编辑了每个单选按钮选项的 GroupName,将它们都称为 Question5。这告诉 excel 它们被分组,即使它们在一个 Group Box 中,eXcel 也没有将它们识别为单独的 Group Boxes。希望这可以帮助!
回答by Julio Nobre
As an alternative to previous answers, I will present a very special technique that I think most of you will just love, in case you are willing to take the effort on following my last Exact Instructions Challenge.
作为对先前答案的替代,我将介绍一种我认为你们中的大多数人都会喜欢的非常特殊的技巧,以防您愿意努力遵循我的上一次精确说明挑战赛。
Since it seems now I caught your attention, let's do it.
既然我现在似乎引起了你的注意,那就去做吧。
Although you must still define at least two Group Boxes, I suggest that you:
尽管您仍然必须至少定义两个Group Boxes,但我建议您:
Add one base Option Buttonanywhere in worksheet outside of any group. You will use this Option Buttonfor replication. You may delete it later, once you are finished
Press ESCtwice, to unselect control;
Point the mouse cursor on base Option Buttonand press Right Click. This will select the control and open a small menu;
Press ESConce. This will close the small menu, but it will keep target control selected;
Now comes the tricky part:
5.1 Press CTRLkey;
5.2 Press mouse LEFT CLICKbutton;
5.3 While keeping both pressed, move you mouse to your target group inner area. This will show a replic of your base control;
5.4 Release your mouse LEFT CLICKbutton. This will create a replic your Option Buttoninside your target group;
5.5 You may now repeat steps 5.2thru 5.4to create any replics you need.
在任何组之外的工作表中的任意位置添加一个基本选项按钮。您将使用此选项按钮进行复制。完成后可以稍后删除
按两次ESC,取消选择控件;
将鼠标光标指向基本Option Button并按Right Click。这将选择控件并打开一个小菜单;
按一次ESC。这将关闭小菜单,但它会保持选中目标控件;
现在是棘手的部分:
5.1 按CTRL键;
5.2 按鼠标左键单击;
5.3 同时按住两个按钮,将鼠标移动到目标组内部区域。这将显示您的基本控件的副本;
5.4 松开鼠标左键单击。这将在您的目标组中创建一个副本您的选项按钮;
5.5 您现在可以重复步骤5.2到5.4以创建您需要的任何副本。
Once you're done, you may release your CTRLkey and delete your base Option Button, selecting it using Right Click, pressing ESCkey once and pressing DELkey.
完成后,您可以松开CTRL键并删除基础Option Button,使用Right Click选择它,按一次ESC键并按DEL键。
For beginners, bear in mind that this neat replication feature (CTRL+LeftClick drag) is widely used on graphical editors.
对于初学者,请记住,这种简洁的复制功能(CTRL+左键拖动)广泛用于图形编辑器。
Hope it helps others from preventing the ridiculous time I did mastering how to overcome this abnoxious UI behavior.
希望它可以帮助其他人避免我掌握如何克服这种令人讨厌的 UI 行为的荒谬时间。