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

Column width and Scrollbar in ContentText

3 Answers 85 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Darko
Top achievements
Rank 1
Darko asked on 22 Sep 2014, 03:52 PM
Hi,

i will attach 2 screen shots to this post. in the first you can see how the first column is almost collapsed and the second pretty wide.
I would like to set the ValueColumn width in code. Here is my current code which is not changing the ColumnWidth no matter which value i put there.

 this._gridError.PropertyGridElement.PropertyTableElement.AutoSizeItems = false;
this._gridError.PropertyGridElement.PropertyTableElement.AutoSizeMode = RadAutoSizeMode.FitToAvailableSize;
this._gridError.PropertyGridElement.PropertyTableElement.ValueColumnWidth = 300;

The second thing I would like to do i to display ScrollBars in the PropertyGridElement.SplitElement.HelpElement.ContentText box.

Thx and best regards,
Darko

3 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 25 Sep 2014, 08:43 AM
Hi Darko,

Thank you for writing.

Internally, RadPropertyGrid sets the ValueColumnWidtproperty when the columns are resized, which means that in theory it should work in your case too. I have created a sample project with RadPropertyGrid and a button. On button click the column's width is changed. Please, take a look and let me know if there is anything that I am missing. I am also converting this forum post to a support thread in order to allow attachments in case you want to attach your own project.

In order to show a scrollbar in the description box you can use the following custom RadPropertyGrid:
public class MyPropertyGrid : RadPropertyGrid
{
    protected override PropertyGridElement CreatePropertyGridElement()
    {
        return new MyPropertyGridElement();
    }
}
 
public class MyPropertyGridElement : PropertyGridElement
{
    protected override PropertyGridSplitElement CreateSplitElement()
    {
        return new MyPropertyGridSplitElement();
    }
 
    protected override Type ThemeEffectiveType
    {
        get
        {
            return typeof(PropertyGridElement);
        }
    }
}
 
public class MyPropertyGridSplitElement : PropertyGridSplitElement
{
    protected override PropertyGridHelpElement CreateHelpElement()
    {
        return new MyPropertyGridHelpElement();
    }
}
 
public class MyPropertyGridHelpElement : PropertyGridHelpElement
{
    private RadScrollViewer scrollViewer;
    private Telerik.WinControls.Layouts.DockLayoutPanel panel;
    private PropertyGridHelpTitleElement titleElement;
    private PropertyGridHelpContentElement contentElement;
 
    protected override void CreateChildElements()
    {
        this.scrollViewer = new RadScrollViewer();
        this.scrollViewer.ShowFill = this.scrollViewer.ShowBorder = false;
 
        this.panel = new Telerik.WinControls.Layouts.DockLayoutPanel();
        panel.LastChildFill = true;
 
        this.titleElement = new PropertyGridHelpTitleElement();
        this.contentElement = new PropertyGridHelpContentElement();
        this.contentElement.TextWrap = true;
        this.panel.Children.Add(this.titleElement);
        Telerik.WinControls.Layouts.DockLayoutPanel.SetDock(this.titleElement, Telerik.WinControls.Layouts.Dock.Top);
        this.panel.Children.Add(this.contentElement);
 
        typeof(PropertyGridHelpElement).GetField("titleElement", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(this, this.titleElement);
        typeof(PropertyGridHelpElement).GetField("contentElement", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(this, this.contentElement);
 
        this.scrollViewer.Viewport = this.panel;
        this.Children.Add(this.scrollViewer);
    }
 
    protected override Type ThemeEffectiveType
    {
        get
        {
            return typeof(PropertyGridHelpElement);
        }
    }
 
    protected override SizeF ArrangeOverride(SizeF finalSize)
    {
        SizeF baseArrange = base.ArrangeOverride(finalSize);
        this.scrollViewer.Arrange(new RectangleF(PointF.Empty, finalSize));
        this.contentElement.MaxSize = new Size((int)finalSize.Width - 17, 0);
        return baseArrange;
    }
}

Let me know how this works out.

Regards,
George
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Darko
Top achievements
Rank 1
answered on 29 Sep 2014, 02:12 PM
tx for the code. The scrollbars are there, the column width is changed if i fire it from a button click, but not if i preset it on form_load or initialize...very strange.
Is it possible to get the description text (PropertyGridElement.SplitElement.HelpElement.ContentText) highlighted and copied to Clipboard?

best regards,
Darko
0
George
Telerik team
answered on 02 Oct 2014, 08:23 AM
Hi Darko,

Thank you for writing.

I tried setting the property at form load, however it seems to be working on my end. Can you make sure that you are not setting it again afterwards? Below you can find a sample project which shows this behavior. I have also replaced the normal element with RadTextBoxControlElement in order to enable highlighting of the text and copy-pasting.

Let me know, should you require further assistance.

Regards,
George
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
PropertyGrid
Asked by
Darko
Top achievements
Rank 1
Answers by
George
Telerik team
Darko
Top achievements
Rank 1
Share this question
or