代码之家  ›  专栏  ›  技术社区  ›  PabloG

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

  •  2
  • PabloG  · 技术社区  · 16 年前

    我正在对表单控件实现自定义行为子分类,但无法访问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);
    
    ...
    

    蒂亚,

    1 回复  |  直到 16 年前
        1
  •  1
  •   PabloG    16 年前

    这个 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

    推荐文章