如何将按钮的大小减小到datagrid视图按钮列的小单元格,同时更改其他列单元格宽度 [英] how to decrese the size of button to a small size inside cell of datagrid view button column with out changing other column cells width

查看:238
本文介绍了如何将按钮的大小减小到datagrid视图按钮列的小单元格,同时更改其他列单元格宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有数据gridview按钮列它的显示按钮罚款....但它占据整个单元格在每一行,如下图..买是列名称...我想调整按钮的大小为椭圆形状......



我该怎么做这个......这是我的按钮列代码的代码....

  DataGridViewButtonColumn column = new DataGridViewButtonColumn(); 
daatgridview1.Columns.Add(column);
column.Resizable = DataGridViewTriState.True;
column.FlatStyle = FlatStyle.Popup;
column.DefaultCellStyle.BackColor = Color.Green;
column.Text =Buy;
column.HeaderText =Buy;
column.UseColumnTextForButtonValue = true;
column.Name =btnbuy;

任何一个人都可以帮助这个......



解决方案

将列样式' Padding 属性设置为适合的填充。它将增加按钮和网格网格线之间的距离。



获取或设置DataGridViewCell的边缘与其内容之间的距离。 - http://msdn.microsoft.com /de-de/library/system.windows.forms.datagridviewcellstyle.padding.aspx



确保将样式设置在正确的图层上你不要单独为每个单元格设置。


Hi i have data gridview button column its displaying button fine .... but it occupies entire cell in every row like below figure .. buy is the column name ...... i want to resize the button to oval shape ......

how can i do this......and this is my code for button column code....

       DataGridViewButtonColumn column = new DataGridViewButtonColumn();
        daatgridview1.Columns.Add(column);
        column.Resizable = DataGridViewTriState.True;
        column.FlatStyle = FlatStyle.Popup;
        column.DefaultCellStyle.BackColor = Color.Green;
        column.Text = "Buy";
        column.HeaderText = "Buy";
        column.UseColumnTextForButtonValue = true;
        column.Name = "btnbuy";

would any one pls help on this one ......

解决方案

Set the column style´d Padding property to a padding that fits. It will increase the distance between your button and the grid´s grid lines.

"Gets or sets the space between the edge of a DataGridViewCell and its content." -- http://msdn.microsoft.com/de-de/library/system.windows.forms.datagridviewcellstyle.padding.aspx

Be sure to set the style on the correct "layer" so you don´t end up setting this for each cell individually.

这篇关于如何将按钮的大小减小到datagrid视图按钮列的小单元格,同时更改其他列单元格宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆