Vb.net iTextsharp和DataGrid颜色冲突
我的代码上有一个DataGrid,代码如下Vb.net iTextsharp和DataGrid颜色冲突,vb.net,itext,Vb.net,Itext,我的代码上有一个DataGrid,代码如下 With MyDataGrid .RowsDefaultCellStyle.BackColor = Color.White .AlternatingRowsDefaultCellStyle.BackColor = Color.LightGray End With 很好 使用Nuget,我使用安装包iTextsharp安装了iTextsharp,然后添加了行 Imports iTextSharp.text.pdf Imports iTe
With MyDataGrid
.RowsDefaultCellStyle.BackColor = Color.White
.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGray
End With
很好
使用Nuget,我使用安装包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
VisualStudio说
属性iTextSharp.text.Font.Color作为基色
获取/设置此字体的颜色
对非共享成员的引用需要对象引用
我认为VisualStudio混淆了Datagrid的Color.White属性和iTextsharp的文本之一
但即使使用此代码(在MyDataGrid之外)
冲突依然存在
如何避免此冲突?您可以通过显式使用system.Drawing color强制它使用所需的系统颜色,这样它就不会试图从其他itextsharp引用中获取颜色前缀:
With MyDataGrid
.RowsDefaultCellStyle.BackColor = System.Drawing.Color.White
.AlternatingRowsDefaultCellStyle.BackColor = System.Drawing.Color.LightGray
End With
您可以通过显式使用system.Drawing颜色强制它使用所需的系统颜色,这样它就不会尝试从其他itextsharp引用中获取颜色前缀:
With MyDataGrid
.RowsDefaultCellStyle.BackColor = System.Drawing.Color.White
.AlternatingRowsDefaultCellStyle.BackColor = System.Drawing.Color.LightGray
End With
简单的解决方案!谢谢,简单的解决方案!谢谢