private string GetTreeviewNodeProperty(string propertyName, TreeNode currentNode) { string value = ""; if (currentNode.Tag != null) { // Break the tag (properties) up into individual property tokens... string[] properties = currentNode.Tag.ToString().Split(';'); foreach (string property in properties) { // If you find the token that contains the property name - retrieve the value if (property.Contains(propertyName)) { // Split it into the key/value pair... string[] keyValuePair = property.Split('='); if (keyValuePair.Length == 2 && keyValuePair[0].Trim() == propertyName.Trim()) { value = keyValuePair[1]; } else if (keyValuePair.Length > 2 && keyValuePair[0].Trim() == propertyName.Trim()) { // The string has more than 1 '=' character in it so use // the first '=' as the delimiter for the key/value pair // (which will inlcude all remaining '=' chars in the value string value = property.Substring(property.IndexOf('=') + 1); } } } } if (string.IsNullOrEmpty(value)) { if (currentNode.Parent != null) { // Didn't find the property - look at the parent's properties... value = GetTreeviewNodeProperty(propertyName, currentNode.Parent); } else { // There is no setting for this property in the tree - get it from the app... value = _sharedUtils.GetAppSettingValue(propertyName); } } return(value); }