在Datagridview VB.Net中保存和检索颜色(如MS Excel) [英] Save and Retrieve Color in Datagridview VB.Net (like MS Excel)

查看:122
本文介绍了在Datagridview VB.Net中保存和检索颜色(如MS Excel)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的所有高级程序员,

您好,您能告诉我在datagridview中保存和检索颜色的链接或源代码吗?

有谁知道该怎么做?

我想在DataGridView(DGV)中存储一种颜色(已由ColorDialog选择). DGV保存到平面文件(.txt)或XML文件中.打开文件并读取内容后,我希望能够将同一DGV的行后颜色设置为每一行的颜色.

预先感谢您提供的任何帮助.


问候,

Agus Salim

Dear all Senior Programmer,

hello, could you show me the link or source code to save and retrieve the color in datagridview ?

Does anyone knows how to do that ?

I want to store a color in a DataGridView(DGV) (that has been selected by the ColorDialog). The DGV saves to a flat file (.txt) or into a XML File. When the file is opened and the contents read I want to be able to set the row back color of the same DGV to the color in each row.

Thank you in advance for any help you can provide.


Regards,

Agus Salim

推荐答案

看看这个例子:
Have a look at this example:
Dim oRow as DataGridViewRow = Nothing

For each oRow in Me.DataGridView1.Rows
    If oRow.Index Mod 2 = 0 Then
        oRow.DefaultCellStyle.Color = Color.Yellow
    Else
        oRow.DefaultCellStyle.Color = Color.Blue
    End if
Next



其余的事情您需要自己做.



The rest you need to do by yourself.


这篇关于在Datagridview VB.Net中保存和检索颜色(如MS Excel)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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