如何在vb.net中更改DataGrid单元格值的ForeColor或BackColor [英] how to change ForeColor or BackColor of DataGrid cell Valuein vb.net

查看:209
本文介绍了如何在vb.net中更改DataGrid单元格值的ForeColor或BackColor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请立即帮助我
如何在vb.net中更改DataGrid(Not DataGridView)单元格的颜色即e(DataGrid.Item(0,0))的颜色


如何更改vb.net中的DataGrid(Not DataGridView)单元格即e(DataGrid.Item(0,0))的彩色背景色

please help me immediately
how to change color forcolor of DataGrid(Not DataGridView) cell vale i.e(DataGrid.Item(0,0)) in vb.net
or

how to change color backcolor of DataGrid(Not DataGridView) cell i.e(DataGrid.Item(0,0)) in vb.net

推荐答案

查看2个链接.一个用于ASP.NET,另一个用于Windows窗体:
更改datagrid单元格属性 [更改DataGrid中单元格的背景颜色 [
Check out the 2 links. One for ASP.NET and the other for Windows forms:
Change datagrid cell properties[^]
Changing the background color of cells in a DataGrid[^]

Good luck!


请标记您的UI库:WPF,Silverlight,Forms,ASP.NET等.
针对 WPF DataGrid 尝试以下解决方案:

如果您要对选定的项目执行此操作,请尝试以下操作:

Please Tag your UI library: WPF, Silverlight, Forms, ASP.NET,etc.
Try out below solution for WPF DataGrid :

If you are doing this for a selected item try this:

var row = (DataGridRow)dataGrid1.ItemContainerGenerator.ContainerFromItem(dataGrid1.SelectedItem);

row.Background = Brushes.<chosen color>;

除此之外,您应该只能设置RowBackground的颜色.

Other than that you should just be able to set the RowBackground color.

dataGrid1.RowBackground = Brushes.<chosen color>;



对于 ASP.NET Windows 表单,您可以参考 E.F.给出的链接. Nijboer



and for ASP.NET and Windows forms you can refer the link given by E.F. Nijboer


这篇关于如何在vb.net中更改DataGrid单元格值的ForeColor或BackColor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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