如何更改DataGridViewHeader上复选框的位置 [英] How to change location of checkbox on DataGridViewHeader

查看:77
本文介绍了如何更改DataGridViewHeader上复选框的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在DataGridViewHeader上绘制了CheckBox,但是我不知道如何更改位置.

这是我的DataGridView的图片

http://imageshack.us/photo/my-images/856/datagrid.jpg/ [ ^ ]

这是我的代码

 ckBox =  CheckBox();
矩形rect =  this  .dataGridView1.GetCellDisplayRectangle( 1 ,-1," > ckBox.Size =  18  EventHandler(ckBox_CheckedChanged);
 .dataGridView1.Controls.Add(ckBox);



请任何人指导我如何更改位置或在单元格的中间固定CheckBox标头.

最后一个问题:我想在标题上调整CheckBox的大小

我已经更改了这行

 ckBox.Size =  Size( 18  ckBox.Size =  Size( 25 解决方案

尝试类似的操作来更改复选框的位置,我不确定它是否会起作用,但请尝试一次

 ckBox.Location =  Point(rect.Location.X + 1,rect.Location.Y + 1); 



如果一切正常,请给我您的反馈.

我在更改CheckBox的大小时有疑问.据我所知,您无法更改CheckBox的大小,这可能是错误的.要验证相同的控件,请在Form上添加新的CheckBox控件,并尝试更改相同控件的大小(如果可以的话),该控件也应在此处正常工作.
如果您还有其他查询,请返回给我.


您可以使用html复选框并添加runat服务器标签,然后使用css更改复选框的大小.

尝试类似的方法:

 < style  type ="text/css">

. mycheckBig  输入 {宽度 :  25像素;  高度  25px; }
. mycheckSmall  输入 {宽度 :  10px;  高度  10px; }

</ 样式 >  




< asp:checkbox id ="CheckBoxBig" runat ="server"已选中=<%#Convert.ToBoolean(Eval(" active))="%& gt;" ="=" autopostback ="False" cssclass ="mycheckBig" xmlns:asp =#unknown">


I''ve drawing CheckBox on my DataGridViewHeader but I don''t know how to change for location.

This is picture of my DataGridView

http://imageshack.us/photo/my-images/856/datagrid.jpg/[^]

And this''s my code

ckBox = new CheckBox();
Rectangle rect = this.dataGridView1.GetCellDisplayRectangle(1, -1,true);
<pre lang="c#">ckBox.Size = new Size(18, 18);
ckBox.Location = rect.Location;
ckBox.CheckedChanged += new EventHandler(ckBox_CheckedChanged);
this.dataGridView1.Controls.Add(ckBox);



Please anyone guild me how to change for location or fixing CheckBox header at the middle of cell.

And last question: I want to resize the CheckBox on header

I''ve change this line

ckBox.Size = new Size(18, 18);



to

ckBox.Size = new Size(25, 25);



But size havn''t changed. Why that??

Thank for helping

解决方案

try some thing like that to change checkbox location, I am not sure it will work or not but try once

ckBox.Location = new Point(rect.Location.X+1, rect.Location.Y+1);



If it works fine give me your feedback.

I have doubt while changing the size of CheckBox. As per my knowledge you cannot change size of CheckBox, I may be wrong. To verify the same add new CheckBox control on Form and try to change the size of same if works there it should work here as well.

If you have any other query revert back to me.


you can use the html check box and add runat server tag , then use css to change the size of the check box.


Try Something like this:

<style type="text/css">

.mycheckBig input {width:25px; height:25px;}
.mycheckSmall input {width:10px; height:10px;}

</style>




<asp:checkbox id="CheckBoxBig" runat="server" checked="<%# Convert.ToBoolean(Eval(" active"))="" %&gt;"="" autopostback="False" cssclass="mycheckBig" xmlns:asp="#unknown">


这篇关于如何更改DataGridViewHeader上复选框的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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