We've had a request to add a close button to each tab in our MDI docking manager rather than use the TdiCloseButton on the far right of the tabstrip. This is similar to Internet Explorer and Firefox's tabbed interface. This is on Q2 2008 SP1.
I've been able to get 99% of the way there but have one nagging little issue I hope you can help with. Whenever I am creating a new MDI child, I am creating a new RadButtonElement via:
private
static Telerik.WinControls.UI.RadButtonElement NewButton()
{
Telerik.WinControls.UI.
RadButtonElement ret = new Telerik.WinControls.UI.RadButtonElement();
(ret.Children[
0] as Telerik.WinControls.Primitives.FillPrimitive).BackColor = System.Drawing.Color.Transparent;
(ret.Children[
0] as Telerik.WinControls.Primitives.FillPrimitive).BackColor2 = System.Drawing.Color.Transparent;
(ret.Children[
0] as Telerik.WinControls.Primitives.FillPrimitive).BackColor3 = System.Drawing.Color.Transparent;
(ret.Children[
2] as Telerik.WinControls.Primitives.BorderPrimitive).Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
ret.MaxSize =
new System.Drawing.Size(16,16);
ret.Text =
"X";
ret.ForeColor = System.Drawing.
Color.Red;
ret.DisplayStyle = Telerik.WinControls.
DisplayStyle.Text;
ret.Alignment = System.Drawing.
ContentAlignment.MiddleRight;
return ret;
}
Then, I add a click handler and increase the ImageTextLayoutPanel's margin to make room for my button and finally add the buttonElement to the children:
Telerik.WinControls.UI.
TabItem tab = pane.DockableTab as Telerik.WinControls.UI.TabItem;
Telerik.WinControls.Layouts.
ImageAndTextLayoutPanel layout = tab.Children[2] as Telerik.WinControls.Layouts.ImageAndTextLayoutPanel;
layout.Margin =
new Padding(0, 0, 20, 0);
Telerik.WinControls.UI.
RadButtonElement button = NewButton();
button.Tag = pane;
button.Click +=
new EventHandler(tab_Close);
button.MouseEnter +=
new EventHandler(closeButton_MouseEnter);
button.MouseLeave +=
new EventHandler(closeButton_MouseLeave);
tab.Children.Add(button);
What I am seeing whenever I add the button element to the tab is the border on the left of the tab is not painted. I've played around with a lot of margin/padding and layout settings but can't seem to get the border to show up correctly. Any suggestions?
Thanks in advance!
I have RadControls for WinForms Q3 2009 SP1.
| Private Sub RadImageButtonElement1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadImageButtonElement1.Click |
| Form1.Close() |
| Me.RadDock1.DockControl(Form1, DockPosition.Fill) |
| Form1.Show() |
| End Sub |