关于DataGrid的一些问题~~~能否解决???

bkss 2002-03-14 08:24:09
最恶心的就是:DataGridTextBoxColumn
这东西居然没有对字体方面的设置,比如想让某一列字为蓝色,就不知道该怎么办。

还有每个CELL开放的属性也太少,比如我要判断每项纪录中的第二列是否是负数,如果是负数那么该行用红色。这个问题很让人头大。

第一个问题我曾经重载过PaintText和Paint,结果也没有用。先将代码提供作为解决这个问题的高手们做参考。
public class dtGTextBoxCol : System.Windows.Forms.DataGridTextBoxColumn
{
public dtGTextBoxCol()
{
//
// TODO: Add constructor logic here
//
}
protected new void PaintText(Graphics g,Rectangle textBounds,string text,Brush backBrush,Brush foreBrush,bool alignToRight)
{
//
//重载对字体设置的方法
//
RectangleF rctf=new RectangleF(textBounds.Left,textBounds.Y,textBounds.Width,textBounds.Height);
Font fnt=new System.Drawing.Font("Arial",10,FontStyle.Bold);
Brush brush=new System.Drawing.SolidBrush(System.Drawing.Color.DarkKhaki);
g.DrawString(text,fnt,foreBrush,rctf);

}
protected new void Paint( Graphics g,Rectangle bounds,CurrencyManager source,int rowNum)
{
string text=source.List[rowNum].ToString();
RectangleF rctf=new RectangleF(bounds.Left,bounds.Y,bounds.Width,bounds.Height);
Font fnt=new System.Drawing.Font("Arial",10,FontStyle.Bold);
Brush brush=new System.Drawing.SolidBrush(System.Drawing.Color.DarkKhaki);
g.DrawString (text,fnt,brush,rctf);
}
}
唉,希望那位高手能帮忙解决一下哦。回家继续想。
...全文
88 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
bkss 2002-03-25
  • 打赏
  • 举报
回复
不过现在解决了行的问题,使用System.Windows.Forms.PaintEventHandler就可以了。谢谢各位~~~~
bkss 2002-03-25
  • 打赏
  • 举报
回复
哦,我忘了说是在WINFORM里面,不是ASP.NET
icyer 2002-03-21
  • 打赏
  • 举报
回复
用模板列。
你想怎么显示都可以。
coco_boy 2002-03-19
  • 打赏
  • 举报
回复
参考以下:(全是自动生成)
<asp:DataGrid id=DataGrid1 style="Z-INDEX: 101; LEFT: 23px; POSITION: absolute; TOP: 33px" runat="server" DataMember="Products" DataSource="<%# DataSet1 %>" Width="365px" Height="144px" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="ProductID" HeaderText="ProductID">
<ItemStyle Font-Size="Larger" Font-Names="YouYuan" BackColor="Red"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="ProductName" HeaderText="ProductName"></asp:BoundColumn>
<asp:BoundColumn DataField="SupplierID" HeaderText="SupplierID"></asp:BoundColumn>
<asp:BoundColumn DataField="CategoryID" HeaderText="CategoryID"></asp:BoundColumn>
<asp:BoundColumn DataField="QuantityPerUnit" HeaderText="QuantityPerUnit"></asp:BoundColumn>
<asp:BoundColumn DataField="UnitPrice" HeaderText="UnitPrice"></asp:BoundColumn>
<asp:BoundColumn DataField="UnitsInStock" HeaderText="UnitsInStock"></asp:BoundColumn>
<asp:BoundColumn DataField="UnitsOnOrder" HeaderText="UnitsOnOrder"></asp:BoundColumn>
<asp:BoundColumn DataField="ReorderLevel" HeaderText="ReorderLevel"></asp:BoundColumn>
<asp:BoundColumn DataField="Discontinued" HeaderText="Discontinued"></asp:BoundColumn>
</Columns>
</asp:DataGrid></FONT>

1,978

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 其他语言讨论
社区管理员
  • 其他语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧