// ** handle styles page private void _lbStyles_SelectedIndexChanged(object sender, System.EventArgs e) { ReportStyle style = _lbStyles.SelectedItem as ReportStyle; _picStyle.Image = (style != null) ? style.GetPreview(false) : null; _owner._defaultStyleName = style.Name; }
// update preview when properties change private void _propGrid_PropertyValueChanged(object s, System.Windows.Forms.PropertyValueChangedEventArgs e) { // update preview ReportStyle style = _list.SelectedItem as ReportStyle; _preview.Image = style.GetPreview(true); // update list if (e.ChangedItem.PropertyDescriptor.Name == "Name") { int index = _list.SelectedIndex; _list.Items[index] = style; } // remember we're dirty _dirty = true; }
// update style preview private void _list_SelectedIndexChanged(object sender, System.EventArgs e) { // get current style ReportStyle style = _list.SelectedItem as ReportStyle; if (style == null) { return; } // update preview _preview.Image = style.GetPreview(false); // we add a readonly attribute to predefined styles so that the grid can be used // to explore it but cannot change it: _propGrid.Enabled = true; if (!style.IsCustom) { var roAttribute = new ReadOnlyAttribute(true); if (!TypeDescriptor.GetAttributes(style).Matches(roAttribute)) { TypeDescriptor.AddAttributes(style, roAttribute); } } // update property grid _propGrid.SelectedObject = style; _propGrid.Refresh(); // only custom styles can be edited: _lblPropGrid.Text = style.IsCustom ? Strings.ReportStyleForm.CustomStyleCaption : Strings.ReportStyleForm.BuiltInStyleCaption; // update buttons _btnRemove.Enabled = style.IsCustom; }