访问 WinCE ComboBox DroppedDown 属性 (.NET CF 2.0)

发布于 2024-09-01 21:52:28 字数 1344 浏览 2 评论 0原文

我正在实现对表单控件进行子类化的自定义行为,但我无法访问 ComboBox 的 DroppedDown 属性。查看帮助,它应该在 CF.NET 2.0 中受支持:

 using System;

 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Drawing;
 using System.Data;
 using System.Text;
 using System.Windows.Forms;

 namespace xCustomControls
 {
     public partial class xComboBox : System.Windows.Forms.ComboBox
     {
         private ComboBox comboBox1;

         public xComboBox()
         {
             InitializeComponent();
             this.KeyDown += new KeyEventHandler(this.KeyDownHandler);
         }

         private void KeyDownHandler(object sender, KeyEventArgs e)
         {
                // DroppedDown doesn't appear in the IntelliSense of ComboBox.
                // or this.comboBox1.
             if (((ComboBox)sender).DroppedDown)     // fail!
                 return;

             switch (e.KeyData)
             {
                 case Keys.Up:
                 case Keys.Enter:
                 case Keys.Down:
                     e.Handled = true;
                     this.Parent.SelectNextControl((Control)sender, e.KeyData != Keys.Up, true, true, true);

...

失败,'System.Windows.Forms.ComboBox' 不包含 'DroppedDown' 的定义,并且没有扩展方法 'DroppedDown' 接受类型为 ' 的第一个参数可以找到 System.Windows.Forms.ComboBox'

如何访问该属性?

TIA, 巴勃罗

I'm implementing custom behavior sub-classing the form controls, but I cannot manage to access the DroppedDown property of the ComboBox. Looking in the help, it's supposed to be supported in CF.NET 2.0:

 using System;

 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Drawing;
 using System.Data;
 using System.Text;
 using System.Windows.Forms;

 namespace xCustomControls
 {
     public partial class xComboBox : System.Windows.Forms.ComboBox
     {
         private ComboBox comboBox1;

         public xComboBox()
         {
             InitializeComponent();
             this.KeyDown += new KeyEventHandler(this.KeyDownHandler);
         }

         private void KeyDownHandler(object sender, KeyEventArgs e)
         {
                // DroppedDown doesn't appear in the IntelliSense of ComboBox.
                // or this.comboBox1.
             if (((ComboBox)sender).DroppedDown)     // fail!
                 return;

             switch (e.KeyData)
             {
                 case Keys.Up:
                 case Keys.Enter:
                 case Keys.Down:
                     e.Handled = true;
                     this.Parent.SelectNextControl((Control)sender, e.KeyData != Keys.Up, true, true, true);

...

fails with 'System.Windows.Forms.ComboBox' does not contain a definition for 'DroppedDown' and no extension method 'DroppedDown' accepting a first argument of type 'System.Windows.Forms.ComboBox' could be found

How can I access the property?

TIA,
Pablo

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡紫姑娘! 2024-09-08 21:52:28

DroppedDown 属性不在紧凑框架中,但您可以使用如下内容:

public const int CB_GETDROPPEDSTATE = 0x0157;
public static bool GetDroppedDown(ComboBox comboBox)
{
 Message comboBoxDroppedMsg = Message.Create(comboBox.Handle, CB_GETDROPPEDSTATE, IntPtr.Zero, IntPtr.Zero);

 MessageWindow.SendMessage(ref comboBoxDroppedMsg);

 return comboBoxDroppedMsg.Result != IntPtr.Zero;
}

取自:http://msdn.microsoft.com/en-us/netframework/bb735847.aspx

The DroppedDown property is not in the compact-framework, but you can use some thing like this:

public const int CB_GETDROPPEDSTATE = 0x0157;
public static bool GetDroppedDown(ComboBox comboBox)
{
 Message comboBoxDroppedMsg = Message.Create(comboBox.Handle, CB_GETDROPPEDSTATE, IntPtr.Zero, IntPtr.Zero);

 MessageWindow.SendMessage(ref comboBoxDroppedMsg);

 return comboBoxDroppedMsg.Result != IntPtr.Zero;
}

Taken from: http://msdn.microsoft.com/en-us/netframework/bb735847.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文