.net - 如何将 System.Color 转换为 Microsoft Word WdColor?

标签 .net vb.net

在 vb .net 中,如何将 System.Color(或)Color.FromArgb(....) 类型转换为 Microsoft.Office.Interop.Word.WdColor?

最佳答案

the C# answer here.

您需要将其转换为十六进制样式的 RGB:

引用科尔卡梅伦对该答案的评论:

Sum the Red, Green, and Blue values of the named color, multiplying the Green & Blue values by hexadecimal modifiers so that the value is effectively 0xBBGGRR (base doesn't really matter, an integer's an integer), then cast that to the WdColor enumeration type.



示例(从 Cole Cameron 的 C# 示例转换而来):
Dim c As Color = Colors.Blue
Dim wdc = DirectCast(c.R + &H100 * c.G + &H10000 * c.B, Microsoft.Office.Interop.Word.WdColor)

关于.net - 如何将 System.Color 转换为 Microsoft Word WdColor?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36238200/

相关文章:

vb.net - 验证文本框中的小数

c# HttpClient 带有正文的补丁请求?

c# - 将空值转换为字符串 - C#.NET

.net - 如何避免成千上万的不必要的ListView.SelectedIndexChanged事件?

c# - 事件处理程序的匿名方法不是泄漏?

.net - 如何将自定义类的通用列表绑定(bind)到 datagridview 并仅在 VB.NET 中显示特定属性?

vb.net - MustOverride 具有混合访问级别 Get/Set 的属性

json - 如何解析json并在vb.net中读取

c# - 我们如何在#中检查一个数组是否包含另一个数组的一个或多个元素?

c# - itextsharp - CSS 未应用 - C# .NET