protected virtual void OnPlusClick(object sender, DynamicListEventArgs e) { if (blockClickEvent) { blockClickEvent = false; return; } OnExpanding(e); // If OnExpanding displaies an error message, focus is lost, form is closed and we can not access the handle anymore if (e.List.IsDisposed) return; ChildForm frm = new ChildForm(); frm.Closed += delegate { blockClickEvent = true; if (expandedIn != null) expandedIn.Remove(e.List); OnCollapsed(e); plus.RaiseItemChanged(); Timer timer = new Timer(); timer.Interval = 85; timer.Tick += delegate(object sender2, EventArgs e2) { ((Timer)sender2).Stop(); ((Timer)sender2).Dispose(); blockClickEvent = false; }; timer.Start(); }; Point p = e.List.PointToScreen(e.List.GetPositionFromRow(this)); p.Offset(e.List.Columns[0].Width, Height); frm.StartPosition = FormStartPosition.Manual; frm.BackColor = childBorderColor; frm.Location = p; frm.ShowInTaskbar = false; frm.Owner = e.List.FindForm(); VerticalScrollContainer scrollContainer = new VerticalScrollContainer(); scrollContainer.Dock = DockStyle.Fill; DynamicList childList = new DynamicList(childColumns, childRows); childList.Dock = DockStyle.Fill; childList.KeyDown += delegate(object sender2, KeyEventArgs e2) { if (e2.KeyData == Keys.Escape) { frm.Close(); // workaround focus problem: sometimes the mainform gets focus after this e.List.FindForm().Focus(); } }; scrollContainer.Controls.Add(childList); frm.Controls.Add(scrollContainer); int screenHeight = Screen.FromPoint(p).WorkingArea.Bottom - p.Y; screenHeight -= frm.Size.Height - frm.ClientSize.Height; int requiredHeight = childList.TotalRowHeight + 4; int formHeight = Math.Min(requiredHeight, screenHeight); if (formHeight < requiredHeight) { int missingHeight = Math.Min(100, requiredHeight - formHeight); formHeight += missingHeight; frm.Top -= missingHeight; } // Autosize child window int formWidth; using (Graphics g = childList.CreateGraphics()) { formWidth = 8 + childList.GetRequiredWidth(g); } int screenWidth = Screen.FromPoint(p).WorkingArea.Right - p.X; if (formWidth > screenWidth) { int missingWidth = Math.Min(100, formWidth - screenWidth); formWidth = screenWidth + missingWidth; frm.Left -= missingWidth; } frm.ClientSize = new Size(formWidth, formHeight); frm.MinimumSize = new Size(100, Math.Min(50, formHeight)); isOpeningChild = true; frm.Show(); isOpeningChild = false; childList.Focus(); if (expandedIn != null) expandedIn.Add(e.List); OnExpanded(e); plus.RaiseItemChanged(); }
protected virtual void OnPlusClick(object sender, DynamicListEventArgs e) { if (blockClickEvent) { blockClickEvent = false; return; } OnExpanding(e); // If OnExpanding displaies an error message, focus is lost, form is closed and we can not access the handle anymore if (e.List.IsDisposed) { return; } ChildForm frm = new ChildForm(); frm.Closed += delegate { blockClickEvent = true; if (expandedIn != null) { expandedIn.Remove(e.List); } OnCollapsed(e); plus.RaiseItemChanged(); Timer timer = new Timer(); timer.Interval = 85; timer.Tick += delegate(object sender2, EventArgs e2) { ((Timer)sender2).Stop(); ((Timer)sender2).Dispose(); blockClickEvent = false; }; timer.Start(); }; Point p = e.List.PointToScreen(e.List.GetPositionFromRow(this)); p.Offset(e.List.Columns[0].Width, Height); frm.StartPosition = FormStartPosition.Manual; frm.BackColor = childBorderColor; frm.Location = p; frm.ShowInTaskbar = false; frm.Owner = e.List.FindForm(); VerticalScrollContainer scrollContainer = new VerticalScrollContainer(); scrollContainer.Dock = DockStyle.Fill; DynamicList childList = new DynamicList(childColumns, childRows); childList.Dock = DockStyle.Fill; childList.KeyDown += delegate(object sender2, KeyEventArgs e2) { if (e2.KeyData == Keys.Escape) { frm.Close(); // workaround focus problem: sometimes the mainform gets focus after this e.List.FindForm().Focus(); } }; scrollContainer.Controls.Add(childList); frm.Controls.Add(scrollContainer); int screenHeight = Screen.FromPoint(p).WorkingArea.Bottom - p.Y; screenHeight -= frm.Size.Height - frm.ClientSize.Height; int requiredHeight = childList.TotalRowHeight + 4; int formHeight = Math.Min(requiredHeight, screenHeight); if (formHeight < requiredHeight) { int missingHeight = Math.Min(100, requiredHeight - formHeight); formHeight += missingHeight; frm.Top -= missingHeight; } // Autosize child window int formWidth; using (Graphics g = childList.CreateGraphics()) { formWidth = 8 + childList.GetRequiredWidth(g); } int screenWidth = Screen.FromPoint(p).WorkingArea.Right - p.X; if (formWidth > screenWidth) { int missingWidth = Math.Min(100, formWidth - screenWidth); formWidth = screenWidth + missingWidth; frm.Left -= missingWidth; } frm.ClientSize = new Size(formWidth, formHeight); frm.MinimumSize = new Size(100, Math.Min(50, formHeight)); isOpeningChild = true; frm.Show(); isOpeningChild = false; childList.Focus(); if (expandedIn != null) { expandedIn.Add(e.List); } OnExpanded(e); plus.RaiseItemChanged(); }