DevExpress設置TreeList圖片節點配景色的辦法。本站提示廣大學習愛好者:(DevExpress設置TreeList圖片節點配景色的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是DevExpress設置TreeList圖片節點配景色的辦法正文
本文實例展現了DevExpress設置TreeList圖片節點配景色的辦法,在項目開辟中有必定的運用價值,詳細辦法以下所示:
重要功效代碼以下:
/// <summary> /// 設置圖片節點的配景色 /// 解釋:在CustomDrawNodeImages事宜中應用 /// </summary> /// <param name="tree">TreeList</param> /// <param name="e">CustomDrawNodeImagesEventArgs</param> /// <param name="builderBackColorHandler">拜托</param> public static void CustomImageNodeBackColor(this TreeList tree, CustomDrawNodeImagesEventArgs e, Func<TreeListNode, Color> builderBackColorHandler) { TreeListNode _node = e.Node; Color _backColor = builderBackColorHandler(_node); e.Graphics.FillRectangle(new SolidBrush(_backColor), e.Bounds); }
代碼應用辦法以下:
private void tlLHData_CustomDrawNodeImages(object sender, CustomDrawNodeImagesEventArgs e) { try { tlLHData.CustomImageNodeBackColor(e, node => { string _cabId = node.GetKeyID(); CCabInfo _cabInfo = LHDBHelper.GetCabInfo(_cabId); if (_cabInfo != null) { return _cabInfo.CtuOnlineStatus == 1 ? Color.White : Color.LightGray; } return Color.White; }); } catch (Exception) { } }
代碼運轉後果以下圖所示:
g System; using System.Collections.Generic; using System.Collections; using System.Linq; using System.Text; using System.Configuration; namespace AppConfig { class Program { static void Main(string[] args) { Console.WriteLine("ConnectionStrings:"); // ConfigurationManager.ConnectionStrings是一個ConnectionStringSettingsCollection對象 // 按數字輪回獲得一個個ConnectionStringSettings對象 // 每一個ConnectionStringSettings對象有Name和ConnectionString屬性 for (int i = 0; i < ConfigurationManager.ConnectionStrings.Count; i++) { string name = ConfigurationManager.ConnectionStrings[i].Name; string connectionString = ConfigurationManager.ConnectionStrings[i].ConnectionString; Console.WriteLine(i.ToString() + ". " + name + " = " + connectionString); } //也能夠以下操作,應用ConnectionStringSettings類型來停止foreach遍歷 foreach (ConnectionStringSettings conn in ConfigurationManager.ConnectionStrings) { string name = conn.Name; string connectionString = conn.ConnectionString; Console.WriteLine(name + " = " + connectionString); } //直接獲得conn的值 Console.WriteLine("\r\nGet the value of the node named \"conn\":"); Console.WriteLine(ConfigurationManager.ConnectionStrings["conn"].ConnectionString); Console.WriteLine(""); Console.WriteLine("AppSettings:"); //AppSettings是NameValueConnection類型,應用AllKeys前往一個一切Key構成的字符串數組 string[] keys = ConfigurationManager.AppSettings.AllKeys; for (int i = 0; i < keys.Length; i++) { string key = keys[i]; //經由過程Key來索引Value string value = ConfigurationManager.AppSettings[key]; Console.WriteLine(i.ToString() + ". " + key + " = " + value); } // 沒有NameValuePair如許的對象,所以沒法應用foreach來停止輪回 //直接獲得key1的值 Console.WriteLine("\r\nGet the value of the key named \"key1\":"); Console.WriteLine(ConfigurationManager.AppSettings["key1"]); //pause the process Console.ReadKey(); } } }下面演示了若何遍歷<connectionStrings>,若何遍歷<appSettings>,若何零丁獲得某一個connectionString,若何零丁獲得某個appSetting。年夜家可以珍藏一下,以便今後應用時參考。
App.config和Web.config的語法格局是完整一樣的,只是一個用戶WinForm法式,一個用於Web法式。
App.config在編譯以後,將會被編譯到bin\Debug目次下,文件名為“運用法式名.exe.config”。
關於C#中App.config文件的應用,本文就引見這麼多,願望對您有所贊助,感謝!