当前位置:编程学习 > C#/ASP.NET >>

求指点

动态生成的tabpages里的每一个页面里都动态生成的一个listview,我要怎么用selectindexchange事件去获取选取房间图片的text的值,而且不能在listview中鼠标拖拉效果,同时选取几个房间;代码如下,希望高手提出改正意见:

//窗体加载时间里面:
List<Model.MroomType> list = BLL.Broomsearch.roomtype();
            foreach (Model.MroomType roomtype in list)
            {
                TabPage tp = new TabPage();
                tp.Name = "tabpage" + roomtype.RoomTypeId;
                tp.Text = roomtype.TypeName;
                this.tabControlEx1.TabPages.Add(tp);
                this.tabControlEx1.Width = 40;
                this.tabControlEx1.Height = 40;
                ListView lv = new ListView();
                lv.Name = "listview" + roomtype.RoomTypeId;
                lv.Dock = DockStyle.Fill;
                lv.LargeImageList = this.imageList1;
                BLL.Bformshow.listviewshow(roomtype.RoomTypeId, lv);
                lv.SelectedIndexChanged += new EventHandler(lv_SelectedIndexChanged);
                tp.Controls.Add(lv);
            }
 public void lv_SelectedIndexChanged(object sender, EventArgs e)    
        {
            ListView lv = null;
            if (this.tabControlEx1.SelectedTab != null)                   //获取选中房间图片的listview
            {
                TabPage tp = this.tabControlEx1.SelectedTab;
                lv = (ListView)tp.Controls[0];
            }
            BLL.Bformshow.listviewdo(label1, lv);                    //从listview中获取选中房间的编号,查询并且显示信息;
            BLL.Bformshow.heardgroupshow(label2, lv);
            BLL.Bformshow.abtepriceshow(label3, lv);
            BLL.Bformshow.phoneshow(label4, lv);
            BLL.Bformshow.floorshow(label5, lv);
            BLL.Bformshow.intotimeshow(label6, lv);
            BLL.Bformshow.deposited(label8, lv);
            BLL.Bformshow.listview2show(lv, listView1);
            BLL.Bformshow.usedtime(label7, lv);
        }

为什么这种方法,在加载后,就已近选上了第一个房间,我想一开始是没有选择的,在呢没办,还有上面说的屏蔽鼠标这这空白处的拖拉效果
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,