Completed
Last Updated: 03 Aug 2017 09:56 by ADMIN
ADMIN
George
Created on: 11 Apr 2014 07:46
Category:
Type: Bug Report
0
FIX. RadListView - improve the layout logic of the SimpleListViewVisualItem in order to wrap children properly
Take the following case for example: 

A RadListView with AllowArbitraryItemHeight property set to true and using the following visual and data items:

public class TextBoxListDataItem : ListViewDataItem
{
    public DateTime Date { get; set; }


    public TextBoxListDataItem(DateTime date, string text)
        : base(text)
    {
        this.Date = date;
    }
}


public class TextBoxListItem : SimpleListViewVisualItem
{
    private DockLayoutPanel dockPanel;
    private LightVisualElement dateElement;
    private RadTextBoxControlElement textBox;


    protected override void CreateChildElements()
    {
        base.CreateChildElements();


        this.dockPanel = new DockLayoutPanel()
        {
            LastChildFill = true
        };


        this.Children.Add(this.dockPanel);


        this.dateElement = new LightVisualElement();
        this.dateElement.ForeColor = Color.Green;
        this.dateElement.ShouldHandleMouseInput = false;
        this.dateElement.NotifyParentOnMouseInput = true;
        DockLayoutPanel.SetDock(this.dateElement, Telerik.WinControls.Layouts.Dock.Left);
        this.dockPanel.Children.Add(this.dateElement);


        this.textBox = new RadTextBoxControlElement();
        this.textBox.IsReadOnly = true;
        this.textBox.ShouldHandleMouseInput = true;
        this.textBox.Multiline = true;
        this.textBox.Click += textBox_Click;
        this.dockPanel.Children.Add(this.textBox);
    }


    void textBox_Click(object sender, EventArgs e)
    {
        (this.ElementTree.Control as RadListView).SelectedItem = this.dataItem;
    }


    protected override void SynchronizeProperties()
    {
        base.SynchronizeProperties();


        base.Text = string.Empty;


        TextBoxListDataItem data = this.dataItem as TextBoxListDataItem;
        this.dateElement.Text = data.Date.ToShortDateString();
        this.textBox.Text = data.Text;
        this.textBox.BorderColor = Color.Transparent;
        this.textBox.BackColor = this.BackColor;
        this.textBox.BackColor2 = this.BackColor2;
        this.textBox.BackColor3 = this.BackColor3;
        this.textBox.BackColor4 = this.BackColor4;
    }


    protected override Type ThemeEffectiveType
    {
        get
        {
            return typeof(SimpleListViewVisualItem);
        }
    }
}



When you run the code you will notice that the TextBoxControlElement has more lines than needed. This can be workarounded by changing the ItemSize property manually when the Size of the ListView changes, however this should not be required.


0 comments