www.C-sharpcorner.com
search datagrid
or
http://www.syncfusion.com/FAQ/WinForms/
search datagrid
or
http://www.syncfusion.com/FAQ/WinForms/
解决方案 »
- 新手问下问题。百度限字数不好搜 - =
- 急,急,怎么将checkbox中的值放进数组中?
- 有skin++的skinbuilder呀
- 急!!!为什么我的网页在win2003server下无法显示?
- (50分求解),如何禁止VS2005中DataGridView1点击列标题后排序?
- 使用XML和VIEWSTATE出现的问题,急救!!!
- 如何将从页面中输入的字段和数据库连接并放到数据表中?
- asp.net事件 无法创建应用程序域............. 寻找解决方案
- 创建并把dataset里的内容导入一个XML 文件。告诉我没有权限,怎么办?高手帮忙!!!谢拉
- WinForm的TextBox,怎样让用户只能输入整数???能否对TextBox设置输入格式???
- html页面的显示
- [讨论]C#数据库的设计问题
public class DataGridColoredTextBoxColumn : DataGridTextBoxColumn
{
protected override void Paint(System.Drawing.Graphics g,
System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager
source, int rowNum, System.Drawing.Brush backBrush, System.Drawing.Brush
foreBrush, bool alignToRight)
{
// the idea is to conditionally set the foreBrush and/or backbrush
// depending upon some crireria on the cell value
// Here, we color anything that begins with a letter higher than 'F'
try{
object o = this.GetColumnValueAtRow(source, rowNum);
if( o!= null)
{
char c = ((string)o)[0];
if( c > 'F')
{
// could be as simple as
// backBrush = new SolidBrush(Color.Pink);
// or something fancier...
backBrush = new LinearGradientBrush(bounds,
Color.FromArgb(255, 200, 200),
Color.FromArgb(128, 20, 20),
LinearGradientMode.BackwardDiagonal);
foreBrush = new SolidBrush(Color.White);
}
}
}
catch(Exception ex){ /* empty catch */ }
finally{
// make sure the base class gets called to do the drawing with
// the possibly changed brushes
base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight);
}
}
}
我说过,我是DataGrid直接绑定DataTable,根本没用到什么DataGridSytle。
而且楼上的这种做法只能处理一列,好像两列就没办法了。
因为对于不同的列,paint是一样的,但我用来判断的数据格式就有可能不一样。
另外我的一张DataGrid绑定了不同的DataTable,用上面的方法恐怕会非常非常麻烦。
DataGrid1.Items[i].Cells[j].BackColor = Color.Red;
i,j 是第几行、第几列
DataGrid1.Items[i].Cells[j].BackColor = Color.Red;
i,j 是第几行、第几列
http://expert.csdn.net/Expert/topic/2110/2110057.xml?temp=.1420404
如下:
DataGrid1.Items[1].Cells[1].Attributes["style"]="COLOR: #ff00ff";
System.Windows.Forms.DataGrid 没有items属性,System.web中倒是有,只是我们现在做的时窗体应用程序!
我C#用的时间不长,C#里还有句柄这个概念吗
liduke(天下有雪) 能不能说具体点