原文: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. JSON序列化自己主动过滤NULL值

    使用Newtonsoft.Json.dll 序列化为json时主动将NULL值过滤掉.详细做法: var jSetting = new JsonSerializerSettings {NullValu ...

  2. SAP 中的popup dialog (弹出对话框) 常见实现方法

      方法1: FM:POPUP_TO_CONFIRM(标准对话弹出消息) 有三个button:YES-NO-CANL,可进行对应的逻辑推断 可设定标题,描写叙述问题,不方便对文本进行换行等排版,不能改 ...

  3. javascript数组全排列,数组元素所有组合

    function permute(input) { var permArr = [], usedChars = []; function main(input){ var i, ch; for (i ...

  4. spring mvc 解决csrf跨站请求攻击

    http://www.dewen.net.cn/q/935/spring+mvc+%E8%A7%A3%E5%86%B3csrf%E8%B7%A8%E7%AB%99%E8%AF%B7%E6%B1%82% ...

  5. 5.8 pprint--美观地打印数据

    pprint模块提供了一个美观地打印Python数据结构的方式.假设是要格式化的数据结构里包括了非基本类型的数据,有可能这样的数据类型不会被载入.比方数据类型是文件.网络socket.类等.本模块格式 ...

  6. [tmux] Automate your workflow using tmux scripts

    Do you have a standard workflow that involves setting up a specific tmux layout, or running certain ...

  7. [Compose] 8. A curated collection of Monoids and their uses

    const { List } = require('immutable-ext'); const Right = x => ({ chain : f => f(x), ap : other ...

  8. keepalived.conf 配置文件小结

    vrrp_script vs_mysql_82 {     script "/etc/keepalived/checkMySQL.py -h 192.168.11.82 -P 3306&qu ...

  9. 【9107】Hanoi双塔问题(NOIP2007)

    Time Limit: 10 second Memory Limit: 2 MB 问题描述 给定A,B,C三根足够长的细柱,在A柱上放有2n个中间有孔的圆盘,共有n个不同的尺寸,每个尺寸都有两个相同的 ...

  10. 日志框架logj的使用

    log4j 简介 是什么? Apache的一个开源的.轻量级的.用于日志管理的框架 有什么? Log4j由三个重要的组件构成:日志信息的输出格式,日志信息的优先 级,日志信息的输出目的地. 1,日志信 ...