Blame view

SunVoteARSPPT/Forms/FrmRank.cs 3.2 KB
20c0108c   wutaian   xx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
  /*----------------------------------------------------------------
  // 文件名: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();
          }
  
      }
  }