本文介绍了访问WinCE ComboBox DroppedDown属性(.NET CF 2.0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

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

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);

...

"System.Windows.Forms.ComboBox"失败,其中不包含"DroppedDown"的定义,找不到扩展方法"DroppedDown",该扩展方法接受"System.Windows.Forms.ComboBox"类型的第一个参数.

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

我如何进入酒店?

TIA,巴勃罗

推荐答案

DroppedDown 属性不在紧凑框架中,但是您可以使用以下方法:

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;
}

来自: http://msdn.microsoft.com/zh-我们/netframework/bb735847.aspx

这篇关于访问WinCE ComboBox DroppedDown属性(.NET CF 2.0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 14:22