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

 

源码:

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

namespace WindowsFormsSample
{
 /// <summary>
 /// Summary description for frmSample3.
 /// </summary>
    [Sample("SourceGrid - Standard features", 3, "Editors and Types")]
    public class frmSample3 : System.Windows.Forms.Form
    {
        private SourceGrid.Grid grid;
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public frmSample3()
        {
            //
            // 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.grid = new SourceGrid.Grid();
            this.SuspendLayout();
            //
            // grid
            //
            this.grid.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.grid.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.grid.Location = new System.Drawing.Point(14, 13);
            this.grid.Name = "grid";
            this.grid.OptimizeMode = SourceGrid.CellOptimizeMode.ForRows;
            this.grid.SelectionMode = SourceGrid.GridSelectionMode.Cell;
            this.grid.Size = new System.Drawing.Size(512, 366);
            this.grid.TabIndex = 0;
            this.grid.TabStop = true;
            this.grid.ToolTipText = "";
            //
            // frmSample3
            //
            this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
            this.ClientSize = new System.Drawing.Size(540, 391);
            this.Controls.Add(this.grid);
            this.Name = "frmSample3";
            this.Text = "Cell Editors, Specials Cells, Formatting and Image";
            this.ResumeLayout(false);

        }
        #endregion

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            grid.Redim(61, 3);

            SourceGrid.Cells.Views.Cell titleModel = new SourceGrid.Cells.Views.Cell();
            titleModel.BackColor = Color.SteelBlue;
            titleModel.ForeColor = Color.White;
            titleModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            SourceGrid.Cells.Views.Cell captionModel = new SourceGrid.Cells.Views.Cell();
            captionModel.BackColor = grid.BackColor;

            int currentRow = 0;

            #region Base Types
            grid[currentRow, 0] = new SourceGrid.Cells.Cell("Base Types");
            grid[currentRow, 0].View = titleModel;
            grid[currentRow, 0].ColumnSpan = 3;
            currentRow++;

            //string
            grid[currentRow, 0] = new SourceGrid.Cells.Cell("String");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1] = new SourceGrid.Cells.Cell("String Value", typeof(string));

            currentRow++;

            //double
            grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1] = new SourceGrid.Cells.Cell(1.5, typeof(double));

            currentRow++;

            //int
            grid[currentRow, 0] = new SourceGrid.Cells.Cell("Int");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1] = new SourceGrid.Cells.Cell(5, typeof(int));

            currentRow++;

            //DateTime
            grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTime");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Now, typeof(DateTime));

            currentRow++;

            //Boolean
            grid[currentRow, 0] = new SourceGrid.Cells.Cell("Boolean");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1] = new SourceGrid.Cells.Cell(true, typeof(Boolean));

            currentRow++;
            #endregion

            #region Complex Types
            grid[currentRow, 0] = new SourceGrid.Cells.Cell("Complex Types");
            grid[currentRow, 0].View = titleModel;
            grid[currentRow, 0].ColumnSpan = 3;
            currentRow++;

            //Font
            grid[currentRow, 0] = new SourceGrid.Cells.Cell("Font");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1] = new SourceGrid.Cells.Cell(this.Font, typeof(Font));

            currentRow++;

            //Cursor
            grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cursor");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1] = new SourceGrid.Cells.Cell(Cursors.Arrow, typeof(Cursor));

            currentRow++;

            //Point
            grid[currentRow, 0] = new SourceGrid.Cells.Cell("Point");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1] = new SourceGrid.Cells.Cell(new Point(2, 3), typeof(Point));

            currentRow++;

            //Rectangle
            grid[currentRow, 0] = new SourceGrid.Cells.Cell("Rectangle");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1] = new SourceGrid.Cells.Cell(new Rectangle(100, 100, 200, 200), typeof(Rectangle));

            currentRow++;

            //Image
            grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1] = new SourceGrid.Cells.Image(Properties.Resources.CalcioSmall);

            currentRow++;

            //Enum AnchorStyle
            grid[currentRow, 0] = new SourceGrid.Cells.Cell("AnchorStyle");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1] = new SourceGrid.Cells.Cell(AnchorStyles.Bottom, typeof(AnchorStyles));

            currentRow++;

            //Enum
            grid[currentRow, 0] = new SourceGrid.Cells.Cell("Enum");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1] = new SourceGrid.Cells.Cell(System.Windows.Forms.BorderStyle.Fixed3D, typeof(System.Windows.Forms.BorderStyle));

            currentRow++;

            //String[]
            grid[currentRow, 0] = new SourceGrid.Cells.Cell("String Array");
            grid[currentRow, 0].View = captionModel;
            string[] strArray = new string[] { "Value 1", "Value 2" };
            grid[currentRow, 1] = new SourceGrid.Cells.Cell(strArray, typeof(string[]));

            currentRow++;

            //Double[]
            grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double Array");
            grid[currentRow, 0].View = captionModel;
            double[] dblArray = new double[] { 1, 0.5, 0.1 };
            grid[currentRow, 1] = new SourceGrid.Cells.Cell(dblArray, typeof(double[]));

            currentRow++;
            #endregion

            #region Special Editors
            grid[currentRow, 0] = new SourceGrid.Cells.Cell("Special Editors");
            grid[currentRow, 0].View = titleModel;
            grid[currentRow, 0].ColumnSpan = 3;
            currentRow++;

            //Time
            grid[currentRow, 0] = new SourceGrid.Cells.Cell("Time");
            grid[currentRow, 0].View = captionModel;
            grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Now);
            grid[currentRow, 1].Editor = new SourceGrid.Cells.Editors.TimePicker();

            currentRow++;

            //Double Chars Validation
            grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double Chars Validation"

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值