sourcegrid 应用实例(全部来自官网下载的例子)——background

 

 

源码:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace WindowsFormsSample
{
 /// <summary>
 /// Summary description for frmSample18.
 /// </summary>
 [Sample("SourceGrid - Standard features", 19, "Grid background")]
 public class frmSample19 : System.Windows.Forms.Form
 {
  private SourceGrid.Grid grid1;
  /// <summary>
  /// Required designer variable.
  /// </summary>
  private System.ComponentModel.Container components = null;

  public frmSample19()
  {
   //
   // Required for Windows Form Designer support
   //
   InitializeComponent();
  }

  /// <summary>
  /// Clean up any resources being used.
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if(components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region Windows Form Designer generated code
  /// <summary>
  /// Required method for Designer support - do not modify
  /// the contents of this method with the code editor.
  /// </summary>
  private void InitializeComponent()
  {
            this.grid1 = new SourceGrid.Grid();
            this.SuspendLayout();
            //
            // grid1
            //
            this.grid1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.grid1.Location = new System.Drawing.Point(14, 9);
            this.grid1.Name = "grid1";
            this.grid1.OptimizeMode = SourceGrid.CellOptimizeMode.ForRows;
            this.grid1.SelectionMode = SourceGrid.GridSelectionMode.Cell;
            this.grid1.Size = new System.Drawing.Size(259, 254);
            this.grid1.TabIndex = 0;
            this.grid1.TabStop = true;
            this.grid1.ToolTipText = "";
            //
            // frmSample19
            //
            this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
            this.ClientSize = new System.Drawing.Size(292, 271);
            this.Controls.Add(this.grid1);
            this.Name = "frmSample19";
            this.Text = "GridBackGround";
            this.Load += new System.EventHandler(this.frmSample19_Load);
            this.ResumeLayout(false);

  }
  #endregion

  private void frmSample19_Load(object sender, System.EventArgs e)
  {
   grid1.Redim(20, 20);

            grid1.BackgroundImage = Properties.Resources.BackGround;

   Random rnd = new Random();

   SourceGrid.Cells.Views.Cell transparentView = new SourceGrid.Cells.Views.Cell();
   transparentView.BackColor = Color.Transparent;
   SourceGrid.Cells.Views.Cell semiTransparentView = new SourceGrid.Cells.Views.Cell();
   semiTransparentView.BackColor = Color.FromArgb(50, Color.Blue);

   for (int r = 0; r < grid1.RowsCount; r++)
    for (int c = 0; c < grid1.ColumnsCount; c++)
    {
     if (rnd.Next(0,100) < 50)
      grid1[r,c] = new SourceGrid.Cells.Cell("Opaque");
     else if (rnd.Next(0,100) < 75)
     {
      SourceGrid.Cells.Cell l_Cell = new SourceGrid.Cells.Cell("Transparent");
      l_Cell.View = transparentView;
      grid1[r,c] = l_Cell;
     }
     else
     {
      SourceGrid.Cells.Cell l_Cell = new SourceGrid.Cells.Cell("Transparent 50");
      l_Cell.View = semiTransparentView;
      grid1[r,c] = l_Cell;
     }
    }

            grid1.AutoSizeCells();
  }
 }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值