解决方案 »

  1.   

    http://blog.csdn.net/linux7985/article/details/3562745
    http://tech.ddvip.com/2008-10/122474620781500.html
    网上很多例子的。
      

  2.   

    问题算是有点解决了。我参考了这里:
    http://blog.csdn.net/ku_cha_cha/article/details/5582190
    能在PC上运行成功,在listView中使用comboBox。但是我想在PDA上运行,将项目转成智能设备项目,发现listView和comboBox的一些属性在wince的框架上是没有的,如下所示:
    m_SelectedItem = this.listView1.GetItemAt(e.X, e.Y);
    Rectangle Rect = m_SelectedItem.Bounds;
    还有就是comboBox的Leave事件也不支持。PC上的代码如下:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            ListViewItem m_SelectedItem;          public Form1()
            {
                InitializeComponent();
                InitComboboxAndListView();  
            }        private void InitComboboxAndListView()
            {
                this.listView1.GridLines = true;
                this.listView1.FullRowSelect = true;
                this.comboBox1.Items.Add("科比");
                this.comboBox1.Items.Add("姚明");
                this.comboBox1.Items.Add("杜兰特");
                this.comboBox1.Items.Add("邓肯");            ListViewItem item;
                item = new ListViewItem(1.ToString());
                item.SubItems.Add("姚明");
                item.SubItems.Add("科比");
                listView1.Items.Add(item);
                item = new ListViewItem(2.ToString());
                item.SubItems.Add("邓肯");
                item.SubItems.Add("杜兰特");
                listView1.Items.Add(item);
            }        private void listView1_MouseUp(object sender, MouseEventArgs e)
            {
                try
                {
                    m_SelectedItem = this.listView1.GetItemAt(e.X, e.Y);//先判断是否有选中行  
                    if (m_SelectedItem != null)
                    {
                        //获取选中行的Bounds                    
                        Rectangle Rect = m_SelectedItem.Bounds;
                        //第二列的左侧X坐标                    
                        int LX = listView1.Columns[0].Width;
                        //第二列的右侧X坐标                    
                        int RX = listView1.Columns[0].Width + listView1.Columns[1].Width;
                        //判断是否点在第二列                    
                        if (e.X > RX || e.X < LX)
                        {
                            this.comboBox1.Visible = false;
                            return;
                        }
                        else
                        {
                            //修改Rect的范围使其与第二列的单元格的大小相同,为了好看 ,左边缩进了2个单位                        
                            Rect.X += listView1.Left + listView1.Columns[0].Width + 2;
                            Rect.Y += this.listView1.Top + 2;
                            Rect.Width = listView1.Columns[1].Width + 2;
                            this.comboBox1.Bounds = Rect;
                            this.comboBox1.Text = m_SelectedItem.SubItems[1].Text;
                            this.comboBox1.Visible = true;
                            this.comboBox1.BringToFront();
                            this.comboBox1.Focus();
                        }
                    }
                }
                catch
                {
                } 
            }        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
            {
                m_SelectedItem.SubItems[1].Text = comboBox1.Text;
                comboBox1.Visible = false; 
            }
            private void comboBox1_Leave(object sender, EventArgs e)
            {
                m_SelectedItem.SubItems[1].Text = comboBox1.Text;
                comboBox1.Visible = false;  
            } 
        }
    }能顺利运行。所以想请教下大神们,现在的这种情况,PDA上一些属性和方法缺少,该怎办?或者能不能通过另外的方法实现?
      

  3.   

    补充:上面说的意思是,在PDA上,listView1.GetItemAt这个没有,m_SelectedItem.Bounds没有