• 大小: 9KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-07
  • 语言: 其他
  • 标签: Datagridview  

资源简介

Datagridview合计行,会总行,非常不错,源码代码:调用代码:Maticsoft.Datagridview.SummaryDataGridView.ShowSummary(折旧核算表DataGridView, true, "合计", true, new string[] { "资产原值", "月度折旧额", "预计净残值", "累计折旧" });

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
namespace Maticsoft.Datagridview
{
    public partial class ReadOnlyTextBox : Control
    {
        StringFormat format;
        public ReadOnlyTextBox()
        {
            InitializeComponent();

            format = new StringFormat(StringFormatFlags.NoWrap | StringFormatFlags.FitBlackBox | StringFormatFlags.MeasureTrailingSpaces);
            format.LineAlignment = StringAlignment.Center;

            this.Height = 10;
            this.Width = 10;

            this.Padding = new Padding(2);
        }

        public ReadOnlyTextBox(IContainer container)
        {
            container.Add(this);
            InitializeComponent();

            this.TextChanged += new EventHandler(ReadOnlyTextBox_TextChanged);
        }

        private void ReadOnlyTextBox_TextChanged(object sender EventArgs e)
        {
            if (!string.IsNullOrEmpty(formatString) && !string.IsNullOrEmpty(Text))
            {
                Text = string.Format(formatString Text);
            }
        }

        private Color borderColor = Color.Black;

        private bool isSummary;
        public bool IsSummary
        {
            get { return isSummary; }
            set { isSummary = value; }
        }

        private bool isLastColumn;
        public bool IsLastColumn
        {
            get { return isLastColumn; }
            set { isLastColumn = value; }
        }

        private string formatString;
        public string FormatString
        {
            get { return formatString; }
            set { formatString = value; }
        }


        private HorizontalAlignment textAlign = HorizontalAlignment.Left;
        [DefaultValue(HorizontalAlignment.Left)]
        public HorizontalAlignment TextAlign
        {
            get { return textAlign; }
            set
            {
                textAlign = value;
                setFormatFlags();
            }
        }

        private StringTrimming trimming = StringTrimming.None;
        [DefaultValue(StringTrimming.None)]
        public StringTrimming Trimming
        {
            get { return trimming; }
            set
            {
                trimming = value;
                setFormatFlags();
            }
        }

        private void setFormatFlags()
        {
            format.Alignment = TextHelper.TranslateAligment(TextAlign);
            format.Trimming = trimming;
        }

        public Color BorderColor
        {
            get { return borderColor; }
            set { borderColor = value; }
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            int subWidth = 0;
            Rectangle textBounds;

            if (!s

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        3885  2018-07-31 23:07  ReadOnlyTextBox.cs
     文件        1000  2018-07-31 23:07  ReadOnlyTextBox.Designer.cs
     文件        5998  2018-07-31 23:07  ReadOnlyTextBox.resx
     文件       21486  2018-07-31 23:13  SummaryControlContainer.cs
     文件        1144  2018-07-31 22:59  SummaryControlContainer.Designer.cs
     文件        1893  2018-07-31 23:03  SummaryDataGridView.cs
     文件        2493  2018-07-31 23:07  TextHelper.cs

评论

共有 条评论