【发布时间】:2016-10-29 06:11:07
【问题描述】:
我的代码上的一个 DataGrid 使用类似的代码进行个性化
With MyDataGrid
.RowsDefaultCellStyle.BackColor = Color.White
.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGray
End With
工作正常。
使用 Nuget,我使用 Install-Package iTextSharp 安装了 iTextsharp,然后我添加了这些行
Imports iTextSharp.text.pdf
Imports iTextSharp.text
Imports iTextSharp.text.BaseColor
代码有效,PDF 已创建
但如果我添加行
Imports iTextSharp.text.Font
一行出现冲突
With MyDataGrid
.RowsDefaultCellStyle.BackColor = Color.White
.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGray
End With
Visual Studio 说
属性 iTextSharp.text.Font.Color 作为 BaseColor 获取/设置此字体的颜色 对非共享成员的引用需要对象引用
我认为 Visual Studio 将 Datagrid 的 Color.White 属性与 iTextsharp 的文本之一混淆了。
但即使使用这段代码(在 With MyDataGrid 之外)
MyDataGrid.RowsDefaultCellStyle.BackColor = Color.White
MyDataGrid.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGray
冲突持续
如何避免这种冲突?
【问题讨论】: