码迷,mamicode.com
首页 > 其他好文 > 详细

C#拖放实现餐饮系统转台操作

时间:2014-09-02 00:07:03      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   ar   2014   div   代码   log   html   

      转台是餐饮系统中常用的操作,一般系统都是右键选择弹出目标台界面,然后选择目标台确定,现在我们把需要转的台通过拖动到目标台图标上面就可以实现前面的操作,简单快捷。

转台操作时:

bubuko.com,布布扣

转台成功后:

bubuko.com,布布扣

 

bubuko.com,布布扣
/// <summary>
        /// 当拖动某项时触发
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listView1_ItemDrag(object sender, ItemDragEventArgs e)
        {
            listView1.DoDragDrop(e.Item, DragDropEffects.Move);
        }

        /// <summary>
        /// 鼠标拖动某项至该控件的区域
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listView1_DragEnter(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.Move;
        }

        /// <summary>
        /// 拖动时拖着某项置于某行上方时
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listView1_DragOver(object sender, DragEventArgs e)
        {
            Point ptScreen = new Point(e.X, e.Y);
            Point pt = listView1.PointToClient(ptScreen);
            ListViewItem item = listView1.GetItemAt(pt.X, pt.Y);
            if (item != null)
                item.Selected = true;
        }

        /// <summary>
        /// 结束拖动
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listView1_DragDrop(object sender, DragEventArgs e)
        {
            ListViewItem draggedItem = (ListViewItem)e.Data.GetData(typeof(ListViewItem));//旧目标
            Point ptScreen = new Point(e.X, e.Y);
            Point pt = listView1.PointToClient(ptScreen);
            ListViewItem TargetItem = listView1.GetItemAt(pt.X, pt.Y);//新目标   
            if (null == TargetItem)
            {
                return;
            }
            if (MessageBoxEx.Show("[" + draggedItem.Text + "]转至[" + TargetItem.Text + "]", "询问", 
                MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                var item = draggedItem.Tag as View_TableListModel;
                int tableid = item.ID;
                
            }
            //listView1.Items.Insert(TargetItem.Index, (ListViewItem)draggedItem.Clone());
            //listView1.Items.Remove(draggedItem);
        }
bubuko.com,布布扣

 

C#拖放实现餐饮系统转台操作

标签:blog   http   io   ar   2014   div   代码   log   html   

原文地址:http://www.cnblogs.com/starksoft/p/3950473.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!