原文:wpf listbox 选中项 上移下移

private void MoveUp_Click(object sender, RoutedEventArgs e)

        {

            DataRowView rowView = this.listScrip.SelectedItem as DataRowView;

            if (rowView == null)

            {

                return;

            }

            DataRow selRow = rowView.Row;

            int index = dtScrip.Rows.IndexOf(selRow);

            if (index == 0)

            {

                return;

            }

            DataRow newRow = dtScrip.NewRow();

            newRow.ItemArray = dtScrip.Rows[index].ItemArray;             

            dtScrip.Rows.Remove(selRow);

            dtScrip.Rows.InsertAt(newRow, index - 1);

            this.listScrip.SelectedIndex = index - 1;

        }

        private void MoveDown_Click(object sender, RoutedEventArgs e)

        {

            DataRowView rowView = this.listScrip.SelectedItem as DataRowView;

            if (rowView == null)

            {

                return;

            }

            DataRow selRow = rowView.Row;

            int index = dtScrip.Rows.IndexOf(selRow);

            if (index == dtScrip.Rows.Count - 1)

            {

                return;

            }

            DataRow newRow = dtScrip.NewRow();

            newRow.ItemArray = dtScrip.Rows[index].ItemArray;

            dtScrip.Rows.Remove(selRow);

            dtScrip.Rows.InsertAt(newRow, index + 1);

            this.listScrip.SelectedIndex = index + 1;

        }

wpf listbox 选中项 上移下移的更多相关文章

  1. WPF学习笔记——设置ListBox选中项的背景颜色

    ListBox的选中项,在我这个WIN7里面,是亮蓝色,颜色是如此之浓厚,差不多遮盖了前景的字体! 太不协调了.可是怎么设置呢?设置触发器,又是IsMouseOver,又是IsFocused,在谷歌里 ...

  2. WPF ListBox

    记录一些ListBox的用法 设置ListBox选中项的背景颜色 如何为标准的ListBox添加ItemClick事件 连续选择同一项时SelectionChanged 事件不响应的问题 1.设置Li ...

  3. 自定义WPF ListBox的选中项样式

    首先介绍一种简单地方法:就是通过自定义SystemColors类的参数来自定义WPF ListBox选择颜色的,SystemColors的HighlightBrushKey和HighlightText ...

  4. WPF中修改ListBox项的样式病修改选中项的背景颜色

    最终效果: 1 <ListBox Name="cmb"> 2 <!--修改颜色--> 3 <ListBox.Resources> 4 <! ...

  5. wpf Listbox 实现按住ctrl键来取消选中

    1. 首先继承一个listbox,来获得按住ctrl键时,点击的item public class ListBoxEx : ListBox { public BeatTemplateWave GetA ...

  6. wpf datagrid设置右键菜单打开时选中项的背景色

    原文:wpf datagrid设置右键菜单打开时选中项的背景色 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/huangli321456/artic ...

  7. wpf ComboBox 获取选中项的文本内容

    一:根据数据源类型获取选中项 类: public class Region { public int REGION_ID { get; set; } public string REGION_CODE ...

  8. 自定义WPF ListBox的选择样式

    (下图:进行多项选择的ListBox) 首先介绍一种简单地方法:就是通过自定义SystemColors类的参数来自定义WPF ListBox选择颜色的,SystemColors的HighlightBr ...

  9. 在C#中实现listbox的项上下移动(winform) 标准

      在C#中实现listbox的项上下移动(winform) 收藏人:梅毛子360   2013-10-02 | 阅:1  转:2  |  分享    |    来源              usi ...

随机推荐

  1. Cash Loan----:利用脚本自动化部署系统,解放我们的双手

    [前言] 现在我们的项目发布(从git上拉代码部署到Linux上)是通过脚本来完成,生产和测试环境都是运维在控制,开发联调环境由开发来负责,之前开发环境每次部署都是先在本地打好jar包然后传到服务器上 ...

  2. web.xml(8)_jsp-config

    13.jsp-config jsp-config元素主要用来设定JSP的相关配置,<jsp:config>包含<taglib>和<jsp-property-group&g ...

  3. [SCSS] Use Standard Built-in SCSS Functions for Common Operations

    We can use javascript for color and opacity variations, math, list and map logic or to see if someth ...

  4. js进阶 11-14 jquery如何实现元素的替换和遍历

    js进阶  11-14  jquery如何实现元素的替换和遍历 一.总结 一句话总结:替换:replaceAll() 与 replaceWith().遍历:each(). 1.replaceAll() ...

  5. 在线生成 QR Code

    http://tool.oschina.net/qr 在线生成二维码(QR码)-采用ZXing与d-project

  6. phpstorm常用快捷键有哪些(图解归类)

    phpstorm常用快捷键有哪些(图解归类) 一.总结 一句话总结: 10.方法参数提示,显示默认参数   解答:--------CTRL+P 13.显示类层级关系图,继承/实现关系   解答:--- ...

  7. [Angular] Some performance tips

    The talk from here. 1. The lifecycle in Angular component: constructor vs ngOnInit: Constructor: onl ...

  8. NOIP模拟 Game - 简单博弈,dp

    题意: 有n个带权球,A和B两个人,A先手拿球,一开始可以拿1个或2个,如果前一个人拿了k个,那么当前的这个人只能那k或k+1个,如果当前剩余的球不足,那么剩下的球都作废,游戏结束.假设两个人都是聪明 ...

  9. 在视图上创建ListCtrl的做法

    作者:朱金灿 来源:http://blog.csdn.net/clever101 今天介绍下如何在一个视图上动态创建一个ListCtrl. 1.新建一个MFC的单文档工程,这里暂定名字为ListDem ...

  10. java基础——try catch final

    1.不管有木有出现异常,finally块中代码都会执行: 2.当try和catch中有return时,finally仍然会执行: 3.finally是在return后面的表达式运算后执行的(此时并没有 ...