• 新建显示病人信息控件PatientElement
    Add-->NewItem-->WPF-->UserControl(WPF),名称:PatientElement.xmal

  • <UserControl x:Class="WPF_OPDrug.PatientElement"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    mc:Ignorable="d"
    d:DesignHeight="" d:DesignWidth="">
    <Grid Margin="">
    <Border BorderThickness="" Background="CadetBlue" BorderBrush="DarkGray"> <StackPanel Orientation="Horizontal" >
    <Image Name="image_photo" Height="" Width="" Source=""></Image>
    <StackPanel Orientation="Vertical">
    <StackPanel Orientation="Horizontal">
    <TextBlock Name="block_PatName" Text="{Binding GivenName}" VerticalAlignment="Center" Margin="1,5" FontSize=""></TextBlock>
    <TextBlock Name="block_PatId" Text="{Binding Id}" VerticalAlignment="Center" Margin="2,5" FontSize="" Foreground="Navy"/>
    <TextBlock Name="block_Sex" Text="{Binding SexId}" VerticalAlignment="Center" Margin="1,5" FontSize="" Foreground="Navy"></TextB
    </StackPanel>
    <StackPanel>
    <TextBlock Name="block_Age" Text="{Binding Birthday}" VerticalAlignment="Center" Margin="2,5" FontSize="" Foreground="Navy"></TextBlock>
    <TextBlock Name="block_condition" Margin="5,0" FontSize="" Foreground="Navy" Width="auto" TextWrapping="Wrap">病情</TextBlock>
    </StackPanel>
    </StackPanel>
    </StackPanel>
    </Border>
    </Grid>
    </UserControl>
  • 在DataOP.cs中写函数从数据库model中获取信息获取
  •  /// <summary>
    /// 获取patient的必要个人信息
    /// </summary>
    ///
    public List<Patient> GetPatInfor()
    {
    var patient = (from p in his.Patient
    select new
    {
    GivenName = p.GivenName,
    Id=p.Id,
    SexId = p.SexId,
    Birthday = p.Birthday
    }).ToList().Select(o => new Patient
    {
    GivenName = o.GivenName,
    Id = o.Id,
    SexId = o.SexId,
    Birthday = o.Birthday
    }).ToList();
    return patient;
    }
  • 显示病人信息的PatientWin.xmal
  • <Window x:Class="WPF_OPDrug.PatientWin"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="PatientWin" WindowState="Maximized" Background="CadetBlue">
    <Grid>
    <Border Name="queryBorder" BorderThickness="">
    <Grid Name="grid_Query">
    </Grid>
    </Border>
    </Grid>
    </Window>
  • 病人信息先行后列显示
  • /// <summary>
    /// //上下滑动显示,先行后列
    /// </summary>
    private void AddUpToDown()
    {
    List<Patient> pat = dataOP.GetPatInfor();
    int count = pat.Count;
    //定义行数=屏幕宽度/控件宽度;列数=病人总数/行数
    int cols = (int)(Convert.ToDouble(SystemParameters.WorkArea.Width) / );
    int rows = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(count) / cols));
    //为grid_Query添加行
    for (int ri = ; ri < rows; ri++)
    {
    RowDefinition row = new RowDefinition();
    row.Height = new GridLength();
    grid_Query.RowDefinitions.Add(row);
    }
    //为grid_Query添加列
    for(int ci=;ci<cols;ci++)
    {
    ColumnDefinition col=new ColumnDefinition();
    col.Width = new GridLength();
    grid_Query.ColumnDefinitions.Add(col);
    } int colNum = ;
    int rowNum = ; for (int i = ; i < count; i++)
    {
    PatientElement patient = new PatientElement();
    patient.block_PatName.Text = pat[i].GivenName.ToString();
    patient.block_PatId.Text = pat[i].Id.ToString();
    patient.block_Sex.Text = pat[i].SexId.ToString();
    patient.block_Age.Text = Convert.ToDateTime(pat[i].Birthday).ToString(); if (colNum == cols)
    {
    rowNum++;
    colNum = ;
    }
    patient.SetValue(Grid.ColumnProperty, colNum);
    patient.SetValue(Grid.RowProperty, rowNum);
    colNum++;
    grid_Query.Children.Add(patient);
    }
    }
  • 病人信息先列后行显示
  • /// <summary>
    /// 左右滑动,先列后行
    /// </summary>
    /// <returns></returns>
    private void AddLeftToRight()
    {
    List<Patient> pat = dataOP.GetPatInfor();
    int count = pat.Count; //由于每行要放置病人信息控件个数:即每行最多能放的个数
    int rows = (int)(Convert.ToDouble(SystemParameters.WorkArea.Height) / ); //*定义行数
    int cols = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(count) / rows));//*定义列数 //为queryGrid添加rows行
    for (int ri = ; ri < rows; ri++)
    {
    RowDefinition rd = new RowDefinition();
    rd.Height = new GridLength();
    grid_Query.RowDefinitions.Add(rd);
    }
    //为queryGrid添加cols列
    for (int ci = ; ci <cols; ci++)
    {
    ColumnDefinition cd = new ColumnDefinition();
    cd.Width = new GridLength();
    grid_Query.ColumnDefinitions.Add(cd);
    } int rowNum = ;
    int colNum = ; for (int i = ;i < count; i++)
    {
    PatientElement patient = new PatientElement();
    patient.block_PatName.Text = pat[i].GivenName.ToString();
    patient.block_PatId.Text = pat[i].Id.ToString();
    patient.block_Sex.Text = pat[i].SexId.ToString();
    patient.block_Age.Text = pat[i].Birthday.ToString(); if (rowNum == rows)
    {
    colNum++;
    rowNum = ;
    }
    patient.SetValue(Grid.ColumnProperty, colNum);
    patient.SetValue(Grid.RowProperty, rowNum);
    rowNum++;
    grid_Query.Children.Add(patient);
    }
    }

WPF:行列显示的更多相关文章

  1. WPF 图片显示中的保留字符问题

    在WPF中显示一张图片,本是一件再简单不过的事情.一张图片,一行XAML代码即可. 但是前段时间遇到了一件奇怪的事: 开发机上运行正常的程序,在某些客户机器上却显示不了图片,而且除了这个问题,其它运行 ...

  2. 在WPF中显示动态GIF

    在我们寻求帮助的时候,最不愿意听到的答复是:很抱歉,在当前版本的产品中还没有实现该功能... 在WPF中显示动态的GIF图像时便遇到了这样的问题,WPF中强大的Image控件却不支持动态的GIF(其只 ...

  3. WPF 循环显示列表

    原文:WPF 循环显示列表 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/SANYUNI/article/details/79423707 项目需要 ...

  4. WPF 窗体显示最前端

    原文:WPF 窗体显示最前端 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/jjx0224/article/details/8782845 如何做一 ...

  5. WPF 远程显示原图 当前主页面 工具栏 一个Window页面的元素适用一个效果

    http://www.jb51.net/article/98384.htm 1.wpf远程显示原图: Stretch="Fill" + ; 主要是因为那个950和650,据显示位置 ...

  6. WPF 托盘显示

    本文告诉大家如何在 WPF 实现在托盘显示,同时托盘可以右击打开菜单,双击执行指定的代码 NotifyIcon WPF 通过 Nuget 安装 Hardcodet.NotifyIcon.Wpf 可以快 ...

  7. 在WPF中显示GIF图片并实现循环播放

    WPF中有一个MediaElement媒体控件,可以来播放媒体,同时也可以显示GIF图片.但看到网上有些人说用MediaElement不能加载作为资源或内嵌的资源的GIF图片,我猜他们一定是在前台用X ...

  8. 【Python学习】解决pandas中打印DataFrame行列显示不全的问题

    在使用pandas的DataFrame打印时,如果表太长或者太宽会自动只给前后一些行列,但有时候因为一些需要,可能想看到所有的行列. 所以只需要加一下的代码就行了. #显示所有列 pd.set_opt ...

  9. Winform WPF 窗体显示位置

    WinForm 窗体显示位置 窗体显示的位置首先由窗体的StartPosition决定,FormStartPosition这个枚举值由如下几种情况 // 摘要: // 窗体的位置由 System.Wi ...

随机推荐

  1. MySQL中怎么对varchar类型排序问题

    MySQL中怎么对varchar类型排序问题 在mysql默认order by 只对数字与日期类型可以排序,但对于varchar字符型类型排序好像没有用了,下面我来给各位同学介绍varchar类型排序 ...

  2. 【转载】linux内核笔记之进程地址空间

    原文:linux内核笔记之进程地址空间 进程的地址空间由允许进程使用的全部线性地址组成,在32位系统中为0~3GB,每个进程看到的线性地址集合是不同的. 内核通过线性区的资源(数据结构)来表示线性地址 ...

  3. 经典JSP数据库连接(ORACLE、SQL Server、MySQL)

    1.连接ORACLE8/8I/9I数据库(thin模式) <%@ page language="java" import="java.util.*" pa ...

  4. Metasploit基础命令

    msf > show exploits 列Metasploip的所有可用的渗透测试框架.在MSF终端中可以针对渗透测试中发现的安全漏洞来实施相应的渗透攻击. msf > show auxi ...

  5. Python入门-引号

    Python 接收单引号(' ),双引号(" ),三引号(''' """) 来表示字符串,引号的开始与结束必须的相同类型的. 其中三引号可以由多行组成,编写多行 ...

  6. Binding的源与路径

    1.把控件作为Binding的源 例子:拖动Slider,输入框中的值也会跟着改变,或在输入框中输入数值,滑动条也会自动移动 <Window x:Class="把控件作为Binding ...

  7. Codeforces Round #376 (Div. 2) C. Socks bfs

    C. Socks time limit per test 2 seconds memory limit per test 256 megabytes input standard input outp ...

  8. POJ3009 Curling

    题目链接:http://poj.org/problem?id=3009 题意:从2出发,要到达3, 0可以通过,碰到1要停止,并且1处要变成0, 并且从起点开始沿着一个方向要一直前进,直至碰到1(或者 ...

  9. JSP学习——语法(二)

    1:JSP运行原理和九大隐式对象: 每个JSP 页面在第一次被访问时,WEB容器都会把请求交给JSP引擎(即一个Java程序)去处理.JSP引擎先将JSP翻译成一个_jspServlet(实质上也是一 ...

  10. Codeforces Round #198 (Div. 2)

    A.The Wall 题意:两个人粉刷墙壁,甲从粉刷标号为x,2x,3x...的小块乙粉刷标号为y,2y,3y...的小块问在某个区间内被重复粉刷的小块的个数. 分析:求出x和y的最小公倍数,然后做一 ...