/*---------------------------------------------------------------- // 文件名:FrmRank.cs // 文件功能描述:全屏显示的排行榜窗体 // // // 创建标识:杨斌 2010-06-02 //----------------------------------------------------------------*/ using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Collections; using GeneralLib; namespace SunVoteARSPPT { public partial class FrmRank : Form { DataGridView dgvShowModel; public FrmRank(DataGridView dgvShowModel) { InitializeComponent(); this.dgvShowModel = dgvShowModel; //杨斌 2014-11-06 Screen scrShow = ControlOper.GetSecondScreen(); this.Size = new Size(scrShow.Bounds.Width, scrShow.Bounds.Height); ControlOper.CenterForm(this, true);//杨斌 2014-09-17 } //转到窗体的KeyDown。杨斌 2013-05-15 //private void dgvShow_KeyDown(object sender, KeyEventArgs e) //{ // if (e.KeyCode == Keys.Escape) // this.Close(); //} private void FrmRank_Load(object sender, EventArgs e) { int swidth = dgvShow.Width; int mwidth = dgvShowModel.Width; foreach (DataGridViewColumn dc in dgvShowModel.Columns) { dgvShow.Columns.Add(dc.Name, dc.HeaderText); dgvShow.Columns[dc.Name].Width = Convert.ToInt32(((float)dc.Width / (float)mwidth) * swidth); dgvShow.Columns[dc.Name].SortMode = DataGridViewColumnSortMode.NotSortable; } foreach (DataGridViewRow dr in dgvShowModel.Rows) { ArrayList list = new ArrayList(); foreach (DataGridViewCell dc in dr.Cells) list.Add(dc.Value); object[] o = list.ToArray(); dgvShow.Rows.Add(o); } ControlOper.SetGridRowH(dgvShow);//杨斌 2016-03-04 //杨斌 2012-10-09 string newName = GlobalInfo.SysLanguage.GetSysFontName(); //MessageBox.Show(newName); Font fontOld = dgvShow.ColumnHeadersDefaultCellStyle.Font; dgvShow.ColumnHeadersDefaultCellStyle.Font = new Font(newName, fontOld.Size, fontOld.Style); fontOld = dgvShow.RowsDefaultCellStyle.Font; dgvShow.RowsDefaultCellStyle.Font = new Font(newName, fontOld.Size, fontOld.Style); ControlOper.AutoSizeDataGridViewColumn(dgvShow);//列宽自动适应。杨斌 2012-11-08 } private void lblCell_Click(object sender, EventArgs e) { this.Close(); } //Esc返回。杨斌 2013-05-15 private void FrmRank_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Escape: this.Close(); break; } } //杨斌 2014-08-20 private void dgvShow_Scroll(object sender, ScrollEventArgs e) { dgvShow.ClearSelection(); } } }