private PropertyGridTextBox grid_textbox;
private PropertyGrid property_grid;
private bool resizing_grid;
- private int skipped_grid_items;
private PropertyGridDropDown dropdown_form;
private Form dialog_form;
private ImplicitVScrollBar vbar;
private StringFormat string_format;
private Font bold_font;
private Brush inactive_text_brush;
+ private ListBox dropdown_list;
#endregion
#region Contructors
dialog_form.FormBorderStyle = FormBorderStyle.None;
dialog_form.ShowInTaskbar = false;
- skipped_grid_items = 0;
row_height = Font.Height + font_height_padding;
grid_textbox.Visible = false;
vbar.Value = 0;
vbar.Visible = false;
}
+ UpdateGridTextBoxBounds ((GridEntry)property_grid.SelectedGridItem);
}
- private bool GetScrollBarVisible ()
- {
- if (property_grid.RootGridItem == null)
- return false;
-
- int visibleRows = GetVisibleRowsCount ();
- int openedItems = GetVisibleItemsCount ((GridEntry)property_grid.RootGridItem);
- if (openedItems > visibleRows)
- return true;
- return false;
- }
+ // private bool GetScrollBarVisible ()
+ // {
+ // if (property_grid.RootGridItem == null)
+ // return false;
+ //
+ // int visibleRows = GetVisibleRowsCount ();
+ // int openedItems = GetVisibleItemsCount ((GridEntry)property_grid.RootGridItem);
+ // if (openedItems > visibleRows)
+ // return true;
+ // return false;
+ // }
#region Drawing Code
private void DrawGridItems (GridItemCollection grid_items, PaintEventArgs pevent, int depth, ref int yLoc) {
{
GridEntry entry = this.property_grid.SelectedGridItem as GridEntry;
if (entry != null) {
+ grid_textbox.Text = (string) ((ListBox) sender).SelectedItem;
if (TrySetEntry (entry, (string) ((ListBox) sender).SelectedItem))
UnfocusSelection ();
}
else {
ICollection std_values = entry.AcceptedValues;
if (std_values != null) {
- ListBox listBox = new ListBox ();
- listBox.BorderStyle = BorderStyle.FixedSingle;
+ if (dropdown_list == null)
+ dropdown_list = new ListBox ();
+ dropdown_list.Items.Clear ();
+ dropdown_list.BorderStyle = BorderStyle.FixedSingle;
int selected_index = 0;
int i = 0;
foreach (object obj in std_values) {
- listBox.Items.Add (obj);
+ dropdown_list.Items.Add (obj);
if (entry.ValueText != null && entry.ValueText.Equals (obj))
selected_index = i;
i++;
}
- listBox.Height = row_height * Math.Min (listBox.Items.Count, 15);
- listBox.Width = ClientRectangle.Width - SplitterLocation - (vbar.Visible ? vbar.Width : 0);
- listBox.KeyDown += new KeyEventHandler (listBox_KeyDown);
- listBox.MouseUp+=new MouseEventHandler (listBox_MouseUp);
+ dropdown_list.Height = row_height * Math.Min (dropdown_list.Items.Count, 15);
+ dropdown_list.Width = ClientRectangle.Width - SplitterLocation - (vbar.Visible ? vbar.Width : 0);
+ dropdown_list.KeyDown += new KeyEventHandler (listBox_KeyDown);
+ dropdown_list.MouseUp+=new MouseEventHandler (listBox_MouseUp);
if (std_values.Count > 0)
- listBox.SelectedIndex = selected_index;
- DropDownControl (listBox);
+ dropdown_list.SelectedIndex = selected_index;
+ DropDownControl (dropdown_list);
}
}
}
private void VScrollBar_HandleValueChanged (object sender, EventArgs e)
{
- if (vbar.Value <= 0)
- vbar.Value = 0;
- if (vbar.Value > vbar.Maximum-ClientRectangle.Height/row_height)
- vbar.Value = vbar.Maximum-ClientRectangle.Height/row_height+1;
-
- int scroll_amount = (skipped_grid_items-vbar.Value)*row_height;
-
- if (scroll_amount == 0)
- return;
-
- skipped_grid_items = vbar.Value;
UpdateView ();
}
grid_textbox.ForeColor = SystemColors.ControlText;
grid_textbox.ReadOnly = !entry.IsEditable;
}
-
- int y = -vbar.Value*row_height;
- CalculateItemY (entry, property_grid.RootGridItem.GridItems, ref y);
- int x = SplitterLocation + ENTRY_SPACING + (entry.PaintValueSupported ? VALUE_PAINT_INDENT : 0);
- grid_textbox.SetBounds (x + ENTRY_SPACING, y + ENTRY_SPACING,
- ClientRectangle.Width - ENTRY_SPACING - x - (vbar.Visible ? vbar.Width : 0),
- row_height - ENTRY_SPACING);
+ UpdateGridTextBoxBounds (entry);
grid_textbox.Text = entry.IsMerged && !entry.HasMergedValue ? String.Empty : entry.ValueText;
grid_textbox.Visible = true;
InvalidateItem (entry);
}
}
+ private void UpdateGridTextBoxBounds (GridEntry entry)
+ {
+ if (entry == null)
+ return;
+ int y = -vbar.Value*row_height;
+ CalculateItemY (entry, property_grid.RootGridItem.GridItems, ref y);
+ int x = SplitterLocation + ENTRY_SPACING + (entry.PaintValueSupported ? VALUE_PAINT_INDENT : 0);
+ grid_textbox.SetBounds (x + ENTRY_SPACING, y + ENTRY_SPACING,
+ ClientRectangle.Width - ENTRY_SPACING - x - (vbar.Visible ? vbar.Width : 0),
+ row_height - ENTRY_SPACING);
+ }
+
// Calculates the sum of the heights of all items before the one
//
private bool CalculateItemY (GridEntry entry, GridItemCollection items, ref int y)
internal void ExpandItem (GridEntry item)
{
+ UpdateItem ((GridEntry)property_grid.SelectedGridItem);
Invalidate (new Rectangle (0, item.Top, Width, Height - item.Top));
}
internal void CollapseItem (GridEntry item)
{
+ UpdateItem ((GridEntry)property_grid.SelectedGridItem);
Invalidate (new Rectangle (0, item.Top, Width, Height - item.Top));
}