如何在C#中的組合框中添加'顏色'(不是顏色名稱,顏色本身)作爲一個項目?在.NET Windows應用程序的組合框中添加顏色
0
A
回答
1
您必須使用所有者繪製的組合框。 This article對CodeProject是一個很好的參考。
1
如果您希望在PropertyGrid中使用顏色類型屬性放置對象時提供的顏色選擇器,然後this person has done just that但是他們將其作爲具有下拉按鈕的按鈕。
如果你真的希望它是一個組合框,你不應該覺得我應該考慮太多的麻煩。
0
這裏是我的代碼用於加載的顏色列表組合供用戶選擇:
List<string> colorslist = new List<string>();
string[] allColors = Enum.GetNames(typeof(System.Drawing.KnownColor));
string[] systemEnvironmentColors = new string[(typeof(System.Drawing.SystemColors)).GetProperties().Length];
int index = 0;
foreach (MemberInfo member in (typeof(System.Drawing.SystemColors)).GetProperties())
{
systemEnvironmentColors[index++] = member.Name;
}
foreach (string color in allColors)
{
if (Array.IndexOf(systemEnvironmentColors, color) < 0)
{
colorslist .Add(color);
}
}
cboColors.DataSource = colorslist;
相關問題
- 1. 如何在地鐵應用程序中爲組合框添加顏色?
- 2. Windows應用程序中的多個組合框在.net中
- 3. 在xaml應用程序中設置組合框選定的項目顏色
- 4. 在DataGridView中使用C#.NET自動完成組合框。Windows應用程序
- 5. 在Windows窗體應用程序中分組組合框項目
- 6. WPF組合框的顏色
- 7. 組合框重置爲選擇Windows應用程序中組合框的文本
- 8. 採取從組合框中輸入在Windows Mobile應用程序
- 9. 在Windows Store應用程序中動態填充組合框
- 10. C#組合框顏色
- 11. .NET應用程序設置:製作一組顏色值
- 12. Windows 8 Metro應用程序對話框更改字體顏色
- 13. MFC應用程序中的組合框
- 14. WIX引導程序 - 添加組合框
- 15. 顏色在Windows Server中的WPF應用程序錯誤2012
- 16. 將顏色添加到顏色數組
- 17. 將組合框添加到iphone應用程序
- 18. 如何設置並從.NET組合框中獲取顏色?
- 19. 添加左側邊框顏色編程
- 20. 如何從組合框在C#Windows窗體應用程序
- 21. 添加在我的Windows手機搜索框7應用程序
- 22. WPF組合框禁用背景顏色
- 23. 在.Net Windows應用程序中緩存
- 24. .Net AdControl在Windows應用程序中
- 25. 更改組合框邊框顏色
- 26. 通過.Net應用程序向Windows Azure Active Directory添加用戶
- 27. c#windows應用程序中tabcontrol的背景顏色
- 28. 獲取metro應用程序中的顏色像素(windows 8)
- 29. 顏色組合
- 30. 如何添加組件在.NET應用程序
難道就沒有別的黑客或把戲呢?我相信只有爲此目的纔會有自定義控件。 – Cerebrus 2009-01-29 05:36:12