private void LoadSSOAppsTreeView() { SSOAffiliateApplications ssoAffiliateApps = new SSOAffiliateApplications(); TreeNode parentNode = treeViewSSOApps.Nodes.Add(Constants._SSO_AFFILIATE_ROOT_NODE, Constants._SSO_AFFILIATE_ROOT_NODE); parentNode.ImageIndex = 0; parentNode.SelectedImageIndex = 0; for (int i = 0; i < ssoAffiliateApps.Applications.Count(); i++) { TreeNode affiliateAppNode = parentNode.Nodes.Add(ssoAffiliateApps.Applications[i]); affiliateAppNode.ImageIndex = 1; affiliateAppNode.SelectedImageIndex = 1; SSOAffiliateApplication ssoApp = new SSOAffiliateApplication(); ssoApp.Application = ssoAffiliateApps.Applications[i]; ssoApp.Description = ssoAffiliateApps.Descriptions[i]; ssoApp.ContactInfo = ssoAffiliateApps.ContactInfos[i]; ssoApp.UserAccount = ssoAffiliateApps.UserAccounts[i]; ssoApp.AdminAccount = ssoAffiliateApps.AdminAccounts[i]; ssoApp.Flag = ssoAffiliateApps.Flags[i]; string[] userAccounts = ssoAffiliateApps.UserAccounts[i].Split(';'); Array.Sort(userAccounts); for (int j = 0; j < userAccounts.Count(); j++) { object[] test = SSOHelper.GetWindowsUserMapping(userAccounts[j].Trim(), ssoAffiliateApps.Applications[i]); foreach (var obj in test) { dynamic item = obj; TreeNode userNode = affiliateAppNode.Nodes.Add(userAccounts[j].Trim()); userNode.ImageIndex = 3; userNode.SelectedImageIndex = 3; userNode.Tag = item; userNode.ContextMenuStrip = contextMenuStrip1; } } affiliateAppNode.Tag = ssoApp; } }