// Sets the string list for the control to the strings // loaded from a resource file. private void LoadResources(object sender, EventArgs e) { IResourceService rs = (IResourceService)this.Component.Site.GetService(typeof(IResourceService)); if (rs == null) { throw new Exception("Could not obtain IResourceService."); } IResourceReader rr = rs.GetResourceReader(CultureInfo.CurrentUICulture); if (rr == null) { throw new Exception("Resource file could not be obtained. You may need to create one first."); } IDictionaryEnumerator de = rr.GetEnumerator(); if (this.Control.GetType() == typeof(ResourceTestControl)) { ResourceTestControl rtc = (ResourceTestControl)this.Control; string s1, s2, s3; de.MoveNext(); s1 = (string)((DictionaryEntry)de.Current).Value; de.MoveNext(); s2 = (string)((DictionaryEntry)de.Current).Value; de.MoveNext(); s3 = (string)((DictionaryEntry)de.Current).Value; de.MoveNext(); rtc.resource_strings = new string[] { s1, s2, s3 }; this.Control.Refresh(); } }
// Clears the string list of the associated ResourceTestControl. private void ClearStrings(object sender, EventArgs e) { if (this.Control.GetType() == typeof(ResourceTestControl)) { ResourceTestControl rtc = (ResourceTestControl)this.Control; rtc.resource_strings = new string[] { "Test String #1", "Test String #2" }; this.Control.Refresh(); } }