当前位置: 首页>>代码示例>>C#>>正文


C# DataGridView.CreateGraphics方法代码示例

本文整理汇总了C#中System.Windows.Forms.DataGridView.CreateGraphics方法的典型用法代码示例。如果您正苦于以下问题:C# DataGridView.CreateGraphics方法的具体用法?C# DataGridView.CreateGraphics怎么用?C# DataGridView.CreateGraphics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.DataGridView的用法示例。


在下文中一共展示了DataGridView.CreateGraphics方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckBoxColumnHeaderHandler

		/// ------------------------------------------------------------------------------------
		public CheckBoxColumnHeaderHandler(DataGridViewColumn col)
		{
			Debug.Assert(col != null);
			Debug.Assert(col is DataGridViewCheckBoxColumn);
			Debug.Assert(col.DataGridView != null);

			_col = col;
			_owningGrid = col.DataGridView;
			_owningGrid.HandleDestroyed += HandleHandleDestroyed;
			_owningGrid.CellPainting += HandleHeaderCellPainting;
			_owningGrid.CellMouseMove += HandleHeaderCellMouseMove;
			_owningGrid.CellMouseClick += HandleHeaderCellMouseClick;
			_owningGrid.CellContentClick += HandleDataCellCellContentClick;
			_owningGrid.Scroll += HandleGridScroll;
			_owningGrid.RowsAdded += HandleGridRowsAdded;
			_owningGrid.RowsRemoved += HandleGridRowsRemoved;

			if (!BetterGrid.CanPaintVisualStyle())
				_szCheckBox = new Size(13, 13);
			else
			{
				var element = VisualStyleElement.Button.CheckBox.CheckedNormal;
				var renderer = new VisualStyleRenderer(element);
				using (var g = _owningGrid.CreateGraphics())
					_szCheckBox = renderer.GetPartSize(g, ThemeSizeType.True);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:28,代码来源:CheckBoxColumnHeaderHandler.cs

示例2: CheckBoxColumnHeaderHandler

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Constructor.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public CheckBoxColumnHeaderHandler(DataGridViewColumn col)
		{
			Debug.Assert(col != null);
			Debug.Assert(col is DataGridViewCheckBoxColumn);
			Debug.Assert(col.DataGridView != null);

			m_col = col;
			m_grid = col.DataGridView;
			m_grid.HandleDestroyed += HandleHandleDestroyed;
			m_grid.CellPainting += HandleHeaderCellPainting;
			m_grid.CellMouseMove += HandleHeaderCellMouseMove;
			m_grid.ColumnHeaderMouseClick += HandleHeaderCellMouseClick;
			m_grid.CellContentClick += HandleDataCellCellContentClick;
			m_grid.Scroll += HandleGridScroll;
			m_grid.RowsAdded += HandleGridRowsAdded;
			m_grid.RowsRemoved += HandleGridRowsRemoved;

			if (!Application.RenderWithVisualStyles)
			{
				m_szCheckBox = new Size(13, 13);
			}
			else
			{
				var element = VisualStyleElement.Button.CheckBox.CheckedNormal;
				var renderer = new VisualStyleRenderer(element);
				using (var g = m_grid.CreateGraphics())
					m_szCheckBox = renderer.GetPartSize(g, ThemeSizeType.True);
			}

			m_stringFormat = new StringFormat(StringFormat.GenericTypographic);
			m_stringFormat.Alignment = StringAlignment.Center;
			m_stringFormat.LineAlignment = StringAlignment.Center;
			m_stringFormat.Trimming = StringTrimming.EllipsisCharacter;
			m_stringFormat.FormatFlags |= StringFormatFlags.NoWrap;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:40,代码来源:CheckBoxColumnHeaderHandler.cs

示例3: getMaxWidth

 public static int getMaxWidth(List<string> strings, DataGridView dataGridView)
 {
     Graphics g = dataGridView.CreateGraphics();
     float maxWidth = 0.0f;
     foreach (string s in strings)
     {
         float width = g.MeasureString(s, dataGridView.Font).Width;
         if (width > maxWidth)
             maxWidth = width;
     }
     g.Dispose();
     return (int)Math.Ceiling(maxWidth);
 }
开发者ID:stankela,项目名称:bilten,代码行数:13,代码来源:GridColumnsInitializer.cs

示例4: ConvertDg2Bmp

        public static void ConvertDg2Bmp(
            DataGridView dg,
            string sFilePath)
        {
            dg.Refresh();
            dg.Select();

            Graphics g = dg.CreateGraphics();
            var ibitMap = new Bitmap
                (
                dg.ClientSize.Width,
                dg.ClientSize.Height,
                g);
            Graphics iBitMapGr = Graphics.FromImage(ibitMap);
            IntPtr iBitMapHdc = iBitMapGr.GetHdc();
            IntPtr meHdc = g.GetHdc();

            BitBlt
                (
                    iBitMapHdc,
                    0,
                    0,
                    dg.ClientSize.Width,
                    dg.ClientSize.Height,
                    meHdc,
                    0,
                    0,
                    Src);
            g.ReleaseHdc(meHdc);
            iBitMapGr.ReleaseHdc(iBitMapHdc);

            if (sFilePath == "")
            {
                return;
            }
            ibitMap.Save
                (
                    sFilePath,
                    ImageFormat.Bmp);
        }
开发者ID:Brett1981,项目名称:ReuseableClasses,代码行数:40,代码来源:DataGridViewtoBitMap.cs

示例5: getGridTextWidth

 public static float getGridTextWidth(DataGridView dgw, string text)
 {
     Graphics g = dgw.CreateGraphics();
     // rezultat je smanjen za 5% zato sto kada u gridu namestim velicinu kolone prema najduzem tekstu, velicina
     // teksta koju daje metod MeasureString je nesto veca od velicine kolone.
     float width = g.MeasureString(text, dgw.Font).Width * 0.95f;
     g.Dispose();
     return width;
 }
开发者ID:stankela,项目名称:bilten,代码行数:9,代码来源:Report.cs


注:本文中的System.Windows.Forms.DataGridView.CreateGraphics方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。