• 运行时手动伸缩控件大小


    public partial class PanelX : UserControl
    {
    private Point oldXY;
    //private static PanelX instance;
    //public DataRow dr = null;
    public delegate void RowSelectedEventHandler(object sender, EventArgs e);
    public event RowSelectedEventHandler RowSelected;

    //.. 必须将它设置为最前 一般这样 this.controls.add (panelx);
    public PanelX()
    {
    InitializeComponent();
    //this.BringToFront();
    }

    //public static PanelX Instance
    //{
    // get
    // {
    // if (instance == null)
    // {
    // instance = new PanelX();
    // }
    // return instance;
    // }
    //}

    public new void Show()
    {
    if (!this.Visible)
    this.Visible = true;
    }

    private void btnClose_Click(object sender, EventArgs e)
    {
    if (this.Visible)
    this.Visible = false;
    }

    private void labResize_MouseDown(object sender, MouseEventArgs e)
    {
    if (e.Button == MouseButtons.Left)
    oldXY = new Point(e.X, e.Y);
    }

    private void labResize_MouseMove(object sender, MouseEventArgs e)
    {
    if (e.Button == MouseButtons.Left)
    {
    this.Width += e.X - oldXY.X;
    this.Height += e.Y - oldXY.Y;
    }
    }

    private void PanelX_MouseDown(object sender, MouseEventArgs e)
    {
    if (e.Button == MouseButtons.Left)
    oldXY = new Point(e.X, e.Y);
    }

    private void PanelX_MouseMove(object sender, MouseEventArgs e)
    {
    if (e.Button == MouseButtons.Left)
    {
    this.Left += e.X - oldXY.X;
    this.Top += e.Y - oldXY.Y;
    }
    }

    private void panel1_MouseDown(object sender, MouseEventArgs e)
    {
    if (e.Button == MouseButtons.Left)
    oldXY = new Point(e.X, e.Y);
    }

    private void panel1_MouseMove(object sender, MouseEventArgs e)
    {
    if (e.Button == MouseButtons.Left)
    {
    this.Left += e.X - oldXY.X;
    this.Top += e.Y - oldXY.Y;
    }
    }

    private void dgvDetail_CellClick(object sender, DataGridViewCellEventArgs e)
    {
    if (e.RowIndex > -1)
    {
    DataRow dr = (dgvDetail.SelectedRows[0].DataBoundItem as DataRowView).Row;
    if (RowSelected != null)
    RowSelected(dr, null);
    this.Dispose();
    }
    }

    protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
    {
    if (keyData == Keys.Enter && this.dgvDetail.Focused && this.dgvDetail.SelectedRows.Count > 0)
    {
    DataRow dr = (dgvDetail.SelectedRows[0].DataBoundItem as DataRowView).Row;
    if (RowSelected != null)
    RowSelected(dr, null);
    this.Dispose();
    return true;
    }
    return base.ProcessCmdKey(ref msg, keyData);
    }
    }

  • 相关阅读:
    HL7数据类型分析(1)
    HL7 CDA高级培训
    JAVA开发常用类(二)
    Oracle中函数返回数据集
    Delphi中DLL或Package窗体载入与显示
    在乐山交流医疗保险审核工作
    JAVA开发常用类(一)
    JAVA开发常用类(三)
    Oracle函数返回超长字符串问题
    基于ODP的数据层基类C#源码
  • 原文地址:https://www.cnblogs.com/z5337/p/3704141.html
Copyright © 2020-2023  润新知