X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FManaged.Windows.Forms%2FSystem.Windows.Forms%2FPropertyGridView.cs;h=0b14141eaaf71821a56457a541f3813ff64e3b4a;hb=aa2b260fcc1971023ba32e09b21927fcfb5800b7;hp=3eddedbce19e678dd0be95b6a37d6450e07a1081;hpb=264c06c08365188f3afb4b77cde389d73b1d9e70;p=mono.git diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs index 3eddedbce19..0b14141eaaf 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs @@ -58,6 +58,7 @@ namespace System.Windows.Forms.PropertyGridInternal { private StringFormat string_format; private Font bold_font; private Brush inactive_text_brush; + private ListBox dropdown_list; #endregion #region Contructors @@ -560,19 +561,20 @@ namespace System.Windows.Forms.PropertyGridInternal { 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) { @@ -755,23 +757,25 @@ namespace System.Windows.Forms.PropertyGridInternal { 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); } } } @@ -829,13 +833,7 @@ namespace System.Windows.Forms.PropertyGridInternal { 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 - (GetScrollBarVisible () ? 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); @@ -845,6 +843,18 @@ namespace System.Windows.Forms.PropertyGridInternal { } } + 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)