关闭ComboBox2的DropDown&错误时打开ComboBox1 [英] Close DropDown of ComboBox2 & Open ComboBox1 on Error

查看:56
本文介绍了关闭ComboBox2的DropDown&错误时打开ComboBox1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个级联的ComboBoxes&想关闭Cbo2&出现错误时打开Cbo1

。这些CboBox是在Excel电子表格上,而不是UserForm。


我有以下代码,如果下拉列表打开则重新查询Cbo2到

ListIndex = 0但是我也希望它能够关闭(取消选择,取消列表)Cbo2&

打开(选择,下拉)MsgBox上的Cbo1错误。这可以确保用户首先选择Cbo1的
属性。

展开 | 选择 | Wrap | 行号

解决方案

似乎没有办法明确取消.Dropdown明显的Kevin(不是我能找到的)但是,将焦点设置为另一个控件(如果需要再将其设置回来)似乎可以帮到你。


祝你好运&欢迎来到 Bytes


它不能在MouseDown事件中工作,但在MouseUp中你可以使用SendKeys并发送F4。警告,F4会在没有下拉的情况下进行下拉,我知道无法确定下拉列表的状态。

展开 | 选择 | Wrap | 行号

以下似乎是一个未记录的功能 - 这意味着你已被警告过。


任何使用MSForms.Combobox.Locked属性的操作都会产生下拉列表消失。


例如

以下代码什么都不做,但是调用锁定消息。导致下拉列表消失的属性。

展开 | 选择 | Wrap | 行号


I have several cascading ComboBoxes & would like to close Cbo2 & open Cbo1
when there is an error. These CboBoxes are on an Excel spreadsheet, not a UserForm.

I have the following code, if the Dropdown is opened it requeries Cbo2 to
ListIndex = 0. But I also want it to close (unselect, undrop list) Cbo2 &
open (select, dropdown) Cbo1 on MsgBox error. This insures the user selects
property of Cbo1 first.

Expand|Select|Wrap|Line Numbers

解决方案

There seems to be no way to cancel the .Dropdown explicitly Kevin (not that I could find anyway) however, setting the focus to another control (and then back again if required) seems to do the trick for you.

Good luck & Welcome to Bytes!


It won''t work in the MouseDown event, but in the MouseUp you can use SendKeys and send F4. Warning, the F4 will do a dropdown if it is not already dropped down, and I know of no way of determining the state of the dropdown list.

Expand|Select|Wrap|Line Numbers


The following seems to be an undocumented feature - that means you''ve been warned.

Any operation with MSForms.Combobox.Locked property makes dropdown list dissapear.

e.g.
the following code does nothing, but calling "Lock" property which results in dropdown list disappearing.

Expand|Select|Wrap|Line Numbers


这篇关于关闭ComboBox2的DropDown&错误时打开ComboBox1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆