using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DevExpress.Xpf.Grid;

namespace WpfApplication21
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        private List<Employee> employees;
        private List<Employee> Employees
        {
            get
            {
                if (employees == null)
                    PopulateEmployees();
                return employees;

}
        }
        private void PopulateEmployees()
        {
            employees = new List<Employee>();
            employees.Add(new Employee("Bruce", "Cambell", "Sales Manager", "Education includes a BA in psychology from Colorado State University in 1970. He also completed 'The Art of the Cold Call.' Bruce is a member of Toastmasters International."));
            employees[0].Orders.Add(new Order("Supplier 1", DateTime.Now, "TV", 20));
            employees[0].Orders.Add(new Order("Supplier 2", DateTime.Now.AddDays(3), "Projector", 15));
            employees[0].Orders.Add(new Order("Supplier 3", DateTime.Now.AddDays(3), "HDMI Cable", 50));
            employees.Add(new Employee("Cindy", "Haneline", "Vice President of Sales", "Cindy received her BTS commercial in 1974 and a Ph.D. in international marketing from the University of Dallas in 1981. She is fluent in French and Italian and reads German. She joined the company as a sales representative, was promoted to sales manager in January 1992 and to vice president of sales in March 1993. Cindy is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association."));
            employees[1].Orders.Add(new Order("Supplier 1", DateTime.Now.AddDays(1), "Blu-Ray Player", 10));
            employees[1].Orders.Add(new Order("Supplier 2", DateTime.Now.AddDays(1), "Blu-Ray Player", 10));
            employees[1].Orders.Add(new Order("Supplier 3", DateTime.Now.AddDays(1), "Blu-Ray Player", 10));
            employees[1].Orders.Add(new Order("Supplier 4", DateTime.Now.AddDays(1), "Blu-Ray Player", 10));
            employees.Add(new Employee("Jack", "Lee", "Sales Manager", "Education includes a BA in psychology from Colorado State University in 1970. He also completed 'The Art of the Cold Call.' Jack is a member of Toastmasters International."));
            employees[2].Orders.Add(new Order("Supplier 1", DateTime.Now, "AV Receiver", 20));
            employees[2].Orders.Add(new Order("Supplier 2", DateTime.Now.AddDays(3), "Projector", 15));
            employees.Add(new Employee("Cindy", "Johnson", "Vice President of Sales", "Cindy received her BTS commercial in 1974 and a Ph.D. in international marketing from the University of Dallas in 1981. She is fluent in French and Italian and reads German. She joined the company as a sales representative, was promoted to sales manager in January 1992 and to vice president of sales in March 1993. Cindy is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association."));
        }

private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            gridControl1.ItemsSource = Employees;

}

#region #MasterRowExpanded
        private void TableView_KeyDown(object sender, KeyEventArgs e)
        {
            TableView view = sender as TableView;

// Avoid key processing when focus is within detail views
            // or when a groupo row is focused
            if (!view.IsFocusedView || view.FocusedRowHandle < 0)
                return;
           
            // Process CTRL+* key combination
            if (e.Key == Key.Multiply && ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control))
            {
                bool finalExpandedState = !view.Grid.IsMasterRowExpanded(view.FocusedRowHandle);
                view.Grid.SetMasterRowExpanded(view.FocusedRowHandle, finalExpandedState);
                e.Handled = true;
            }
        }
        #endregion #MasterRowExpanded

#region #ExpandCollapse
        private void buttonExpandAll_Click(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < gridControl1.VisibleRowCount; i++)
            {
                var rowHandle = gridControl1.GetRowHandleByVisibleIndex(i);
                gridControl1.ExpandMasterRow(rowHandle);
            }
        }
        private void buttonCollapseAllButThis_Click(object sender, RoutedEventArgs e)
        {
            if (tableView1.FocusedRowHandle >= 0)
                gridControl1.ExpandMasterRow(tableView1.FocusedRowHandle);
            for (int i = 0; i < gridControl1.VisibleRowCount; i++)
            {
                int rowHandle = gridControl1.GetRowHandleByVisibleIndex(i);
                if (rowHandle != tableView1.FocusedRowHandle)
                    gridControl1.CollapseMasterRow(rowHandle);
            }
        }
        #endregion #ExpandCollapse
    }

public class Employee
    {
        private string firstName;
        private string lastName;
        private string title;
        private string notes;
        private List<Order> orders;
        public Employee(string firstName, string lastName, string title, string notes)
        {
            this.firstName = firstName;
            this.lastName = lastName;
            this.title = title;
            this.notes = notes;
            this.orders = new List<Order>();
        }
        public Employee() { }
        public string FirstName { get { return firstName; } set { firstName = value; } }
        public string LastName { get { return lastName; } set { lastName = value; } }
        public string Title { get { return title; } set { title = value; } }
        public string Notes { get { return notes; } set { notes = value; } }
        public List<Order> Orders { get { return orders; } }
    }

public class Order
    {
        private string supplier;
        private DateTime date;
        private string productName;
        private int quantity;
        public Order(string supplier, DateTime date, string productName, int quantity)
        {
            this.supplier = supplier;
            this.date = date;
            this.productName = productName;
            this.quantity = quantity;
        }
        public string Supplier { get { return supplier; } set { supplier = value; } }
        public DateTime Date { get { return date; } set { date = value; } }
        public string ProductName { get { return productName; } set { productName = value; } }
        public int Quantity { get { return quantity; } set { quantity = value; } }
    }

}

MatserDetail自动展开的更多相关文章

  1. Ztree异步加载自动展开节点

    在Ztree的官网Demo中,有自动展开的例子,是通过设置节点属性open:true来实现自动展开的,但是在异步加载中,这个属性设置为true也不会自动展开,因为open:true是指在有子节点的情况 ...

  2. textarea高度自适应自动展开

    在使用之前,推荐两个比较好的事件,分别是oninput和onpropertychange,IE9以下不兼容oninput.在textarea发生变化时,可以通过监听这两个事件来触发你需要的功能. te ...

  3. telerik:RadGrid 分组自动展开

    在 MasterTableView 加上 GroupsDefaultExpanded = " true " 即可 自动展开分组下面的子项

  4. JS脚本实现CSDN免登陆免关闭广告插件自动展开“阅读更多”内容

    最近在CSDN查资料,总是弹出以下弹窗,然后就自动跳转到登录页面,蛋疼! 于是重新捣腾了一下,修改了原来的脚本,最新的脚本代码如下: 温馨提示:在打开CSDN页面后立刻执行以下脚本即可免登陆免关闭广告 ...

  5. vue + element-ui 制作下拉菜单(可配置路由、可根据路由高亮list、可刷新自动展开定位路由)

    本篇文章分享一篇关于 vue制作可路由切换组件.可刷新根据路由定位导航(自动展开).可根据路由高亮对应导航选项 一.实现的功能如下: 1.可折叠导航面板 2.点击导航路由不同组件           ...

  6. Delphi TreeView – 自动展开树形结构

    Delphi TreeView – 自动展开树形结构 当处理完TreeView控件树形结构的数据后,需要默认自动全部展开,可以用到TreeView的Expanded属性. 1 2 3 4 5 6 7 ...

  7. csdn自动展开+去广告+净化剪切板+免登陆(如有侵权,立即删博)

    对于csdn的广告大家想必......又没钱充VIP,怎么办,下面是脚本源码: 重要的事说三遍:如有侵权,立即删除!如有侵权,立即删除!如有侵权,立即删除! // ==UserScript== // ...

  8. 当打开一个.h或.cpp文件时, Solution Explorer就自动展开文件所在的目录

    当打开一个.h或.cpp文件时,  Solution Explorer就自动展开文件所在的目录: 如果不想展开: Tools           -> Options           -&g ...

  9. Extjs 树菜单的自动展开数据的请求

    今天在做extjs开发的时候,在树菜单上遇到了一个坑,也许是我刚接触extjs 不熟的缘故 问题描述:后台设置的树自动展开,但是在前端总是只显示一条数据,但是数据确实都请求到了. 经过几个小时不屑的努 ...

随机推荐

  1. DFS(7)——poj1011Sticks

    一.题目回顾 题目链接:Sticks 题意:给出一定数量的小木棒的长度,它是由等长的若干木棒随意砍断所得到的.对于给定的一组小木棒,请求出原始木棒的最小长度. 二.解题思路 DFS+剪枝 本题剪枝不到 ...

  2. 关于百度Editor富文本编辑器 自定义上传位置

    因为要在网站上编辑富文本数据,所以直接采用百度的富文本编辑器,但是这个编辑器有个缺点,默认情况下,文件只能上传到网站的根目录,不能自定义路径. 而且json配置文件只能和controller.jsp在 ...

  3. c# 自动关机代码

    #region 关机代码 //C#关机代码 // 这个结构体将会传递给API.使用StructLayout //(...特性,确保其中的成员是按顺序排列的,C#编译器不会对其进行调整. [Struct ...

  4. 软工实践 - 第二十五次作业 Beta 冲刺(3/7)

    队名:起床一起肝活队 组长博客:https://www.cnblogs.com/dawnduck/p/10116979.html 作业博客:班级博客本次作业的链接 组员情况 组员1(队长):白晨曦 过 ...

  5. 图书 Framework 设计指南: 可重用 .NET 库的约定、惯用法和模式 引出资料

    文章:框架设计准则     --微软 地址:https://docs.microsoft.com/zh-cn/dotnet/standard/design-guidelines/index

  6. 下拉框select chosen被遮盖

    最简单的就是让容器高度大点. 用js调整也行. 为什么z-index不管事,看下面... 浏览器支持 所有主流浏览器都支持 z-index 属性. 注释:任何的版本的 Internet Explore ...

  7. To Chromium之VS调试追踪

    启动的code: for(;;){...WaitForWork()}base.dll!base::MessagePumpForUI::DoRunLoop                         ...

  8. PHP判断类型的方法

    1.gettype():获取变量类型 2.is_array():判断变量类型是否为数组类型 3.is_double():判断变量类型是否为倍浮点类型 4.is_float():判断变量类型是否为浮点类 ...

  9. Sublime Text 2创建可复用的代码片段

    对于前端工程师来讲,写一个html页面的基本结构是体力活,每次去拷贝一个也麻烦,sublime text 2 提供了一个很好的复用代码片段.下面介绍一下创建一个html5的代码片段的过程.在菜单上点击 ...

  10. 【NOIP模拟赛】超级树 DP

    这个题我在考试的时候把所有的转移都想全了就是新加一个点时有I.不作为II.自己呆着III.连一个IV.连接两个子树中的两个V连接一个子树中的两个,然而V我并不会转移........ 这个题的正解体现了 ...