This is a migrated thread and some comments may be shown as answers.

problem by raddock

4 Answers 286 Views
Dock
This is a migrated thread and some comments may be shown as answers.
ali
Top achievements
Rank 1
ali asked on 24 Feb 2011, 09:57 PM
hi
i locate raddock on form
and add text to caption but i want set text align to right or center  not left
i select image for raddock but not view image
hot i select image as icon in raddock

4 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 27 Feb 2011, 10:03 AM
Hello Ali,

Sadly i don't really understand what you want to accomplish here, can you please post some screenshots with the desired behavior?

Best Regards,
Emanuel Varga

Telerik WinForms MVP
0
ali
Top achievements
Rank 1
answered on 27 Feb 2011, 04:44 PM
i attached my screenshot for my question
0
Emanuel Varga
Top achievements
Rank 1
answered on 28 Feb 2011, 10:34 AM
Hello ali,

If you want to do this from the designer, please take a look at the attached screenshot for the necessary steps.

If you prefer doing it from code, please take a look at the following sample:
private void SetTextAlignment(ToolTabStrip toolTabStrip, System.Drawing.ContentAlignment alignment)
{
    var dockLayout = toolTabStrip.SplitPanelElement.Children[2] as DockLayoutPanel;
    var captionElement = dockLayout.Children[0] as ToolWindowCaptionElement;
    dockLayout = captionElement.Children[2] as DockLayoutPanel;
    var textPrimitive = dockLayout.Children[3] as TextPrimitive;
 
    textPrimitive.TextAlignment = alignment;
}

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Richard Slade
Top achievements
Rank 2
answered on 28 Feb 2011, 11:33 AM
Hi Guys,

There is an issue with the code here. It will be fine when initially seen, but if you try to drag the ToolWindow to a different position then the Text Alignment will reset back to the original value. I'd suggest a slightly different approach which will work for all dock positions (apart from floating).

Please consider the following

designer
namespace RadControlsWinFormsApp1
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components;
  
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
  
        #region Windows Form Designer generated code
  
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.radDock1 = new Telerik.WinControls.UI.Docking.RadDock();
            this.documentContainer1 = new Telerik.WinControls.UI.Docking.DocumentContainer();
            this.toolWindow1 = new Telerik.WinControls.UI.Docking.ToolWindow();
            this.toolTabStrip1 = new Telerik.WinControls.UI.Docking.ToolTabStrip();
            ((System.ComponentModel.ISupportInitialize)(this.radDock1)).BeginInit();
            this.radDock1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.documentContainer1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.toolTabStrip1)).BeginInit();
            this.toolTabStrip1.SuspendLayout();
            this.SuspendLayout();
            // 
            // radDock1
            // 
            this.radDock1.ActiveWindow = this.toolWindow1;
            this.radDock1.Controls.Add(this.documentContainer1);
            this.radDock1.Controls.Add(this.toolTabStrip1);
            this.radDock1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.radDock1.DocumentManager.DocumentInsertOrder = Telerik.WinControls.UI.Docking.DockWindowInsertOrder.InFront;
            this.radDock1.IsCleanUpTarget = true;
            this.radDock1.Location = new System.Drawing.Point(0, 0);
            this.radDock1.MainDocumentContainer = this.documentContainer1;
            this.radDock1.Name = "radDock1";
            this.radDock1.Padding = new System.Windows.Forms.Padding(5);
            // 
            // 
            // 
            this.radDock1.RootElement.MinSize = new System.Drawing.Size(25, 25);
            this.radDock1.Size = new System.Drawing.Size(541, 419);
            this.radDock1.SplitterWidth = 4;
            this.radDock1.TabIndex = 0;
            this.radDock1.TabStop = false;
            this.radDock1.Text = "radDock1";
            this.radDock1.TransactionCommitted += new Telerik.WinControls.UI.Docking.RadDockTransactionEventHandler(this.radDock1_TransactionCommitted);
            // 
            // documentContainer1
            // 
            this.documentContainer1.Location = new System.Drawing.Point(5, 5);
            this.documentContainer1.Name = "documentContainer1";
            // 
            // 
            // 
            this.documentContainer1.RootElement.MinSize = new System.Drawing.Size(25, 25);
            this.documentContainer1.Size = new System.Drawing.Size(327, 409);
            this.documentContainer1.SizeInfo.SizeMode = Telerik.WinControls.UI.Docking.SplitPanelSizeMode.Fill;
            this.documentContainer1.SplitterWidth = 4;
            this.documentContainer1.TabIndex = 0;
            this.documentContainer1.TabStop = false;
            // 
            // toolWindow1
            // 
            this.toolWindow1.Location = new System.Drawing.Point(1, 24);
            this.toolWindow1.Name = "toolWindow1";
            this.toolWindow1.Size = new System.Drawing.Size(198, 383);
            this.toolWindow1.Text = "toolWindow1";
            // 
            // toolTabStrip1
            // 
            this.toolTabStrip1.Controls.Add(this.toolWindow1);
            this.toolTabStrip1.Location = new System.Drawing.Point(336, 5);
            this.toolTabStrip1.Name = "toolTabStrip1";
            // 
            // 
            // 
            this.toolTabStrip1.RootElement.MinSize = new System.Drawing.Size(25, 25);
            this.toolTabStrip1.SelectedIndex = 0;
            this.toolTabStrip1.Size = new System.Drawing.Size(200, 409);
            this.toolTabStrip1.TabIndex = 1;
            this.toolTabStrip1.TabStop = false;
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(541, 419);
            this.Controls.Add(this.radDock1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            ((System.ComponentModel.ISupportInitialize)(this.radDock1)).EndInit();
            this.radDock1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.documentContainer1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.toolTabStrip1)).EndInit();
            this.toolTabStrip1.ResumeLayout(false);
            this.ResumeLayout(false);
  
        }
  
        #endregion
  
        private Telerik.WinControls.UI.Docking.RadDock radDock1;
        private Telerik.WinControls.UI.Docking.ToolWindow toolWindow1;
        private Telerik.WinControls.UI.Docking.DocumentContainer documentContainer1;
        private Telerik.WinControls.UI.Docking.ToolTabStrip toolTabStrip1;
    }
}

Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls.UI.Docking;
using Telerik.WinControls.Layouts;
using Telerik.WinControls.Primitives;
using Telerik.WinControls.UI;
  
  
namespace RadControlsWinFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
  
        private void Form1_Load(object sender, EventArgs e)
        {
            this.SetTextAlignment(this.toolWindow1, ContentAlignment.MiddleRight);
        }
  
        private void SetTextAlignment(ToolWindow window, System.Drawing.ContentAlignment alignment)
        {
             ((TextPrimitive)(window.DockTabStrip as ToolTabStrip).CaptionElement.Children[2].Children[3]).TextAlignment = alignment;
        }
  
        private void radDock1_TransactionCommitted(object sender, RadDockTransactionEventArgs e)
        {
            if (e.Transaction.AssociatedWindows.Count > 0)
            
                if (e.Transaction.AssociatedWindows[0] is ToolWindow)
                {
                    if (e.Transaction.AssociatedWindows[0].DockState != DockState.Hidden)
                    
                        this.SetTextAlignment((ToolWindow)e.Transaction.AssociatedWindows[0], ContentAlignment.MiddleRight);
                    
                }                
            }
        }
  
    }
}

I will also look at at floating state, and if I can address your question regarding the image. In the meantime, please let me know if you have any questions
Richard
Tags
Dock
Asked by
ali
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
ali
Top achievements
Rank 1
Richard Slade
Top achievements
Rank 2
Share this question
or