简体   繁体   English

更改datagrid中特定单元格的颜色?

[英]Change the color of particular cell in datagrid?

I'm using VS 2008 to create a Windows Mobile program in C#. 我正在使用VS 2008在C#中创建Windows Mobile程序。 I need to display data in a grid. 我需要在网格中显示数据。 The only grid control I could find for Windows Mobile is DataGrid, so I placed one on my form. 我可以为Windows Mobile找到的唯一网格控件是DataGrid,因此我在窗体上放置了一个。 I now need to change the color of particular cell according to some condition. 我现在需要根据某种条件更改特定单元格的颜色。 How do I do this? 我该怎么做呢?

Thanks in advance... 提前致谢...

Usually grids have some kind of "fetching" event; 通常,网格具有某种“获取”事件。 your best solution is a row fetching or, at worst, a cell fetching event. 最好的解决方案是行获取,或者最坏的情况是单元获取事件。 Listening to this, you can trap the moment when the row/cell is being created and apply your style logic. 聆听这一点,您可以捕获创建行/单元格的时间,并应用样式逻辑。 This is true for grids spanning from VB6 to Asp.NET, so I suppose can apply on your case too. 从VB6到Asp.NET的网格都是如此,因此我想也可以适用于您的情况。

Hope this helps! 希望这可以帮助! mt 公吨

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM