Moving away from ObjectListView

9 posts, 2 answers
  1. KKL
    KKL avatar
    15 posts
    Member since:
    Nov 2016

    Posted 07 Jan Link to this post

    Now that we're including the Telerik UI in our project, we'd like to reduce our reliance on third party controls where possible. I'm looking at replacing ObjectListView and I presume the equivalient would be RadListView.

    With ObjectListView the process is:

    1. Define the custom MyClass
    2. Define the columns at design time and associate each with a Property in MyClass
    3. At run time, use SetObjects to set the list content to the run time defined List (of MyClass). 

    Is there a way to do this in RadListView without needing to maintain an external data source, or manually add each item as a new row in the ListView? 

  2. Answer
    Dess
    Admin
    Dess avatar
    2107 posts

    Posted 10 Jan Link to this post

    Hello Kevin,

    Thank you for writing.  

    According to the provided information, I think that RadListView is the suitable control for your case. Data binding is a mechanism for automatic population of RadListView with items, based on the provided data structure. RadListView support data binding either at design time or at run time. Please refer to the following help article demonstrating how to setup data binding: http://docs.telerik.com/devtools/winforms/listview/populating-with-data/data-binding

    RadListView supports three ViewTypes ListView, IconsView and DetailsView. You can use DetailsView which provides a grid-like interface for displaying items with more than one data fields organized in columns.

    You can refer to our Demo application >> ListView >> First Look example which is quite useful for getting started with RadListView. The Demo application is available in the installation folder of the suite which is usually located at the following path: C:\Program Files (x86)\Telerik\UI for WinForms R3 2016\Examples\QuickStart\Bin

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. KKL
    KKL avatar
    15 posts
    Member since:
    Nov 2016

    Posted 10 Jan in reply to Dess Link to this post

    Thank you, sounds like this will work. I couldn't find a way to edit a cell on double-click, rather than having to press F2. Is that possible?
  4. Answer
    Dess
    Admin
    Dess avatar
    2107 posts

    Posted 10 Jan Link to this post

    Hello Kevin, 

    Thank you for writing back. 

    In order to activate the editor after double clicking RadListView, you can use the following code snippet:
    public RadForm1()
    {
        InitializeComponent();
     
        this.radListView1.AllowEdit = true;
        this.radListView1.DoubleClick+=radListView1_DoubleClick;
    }
     
    private void radListView1_DoubleClick(object sender, EventArgs e)
    {
        this.radListView1.BeginEdit();
    }

    I hope this information helps. If you have any additional questions, please let me know. 

    Regards,
    Dess
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. KKL
    KKL avatar
    15 posts
    Member since:
    Nov 2016

    Posted 14 Jan in reply to Dess Link to this post

    Many thanks for you fast response!
  6. KKL
    KKL avatar
    15 posts
    Member since:
    Nov 2016

    Posted 05 Feb Link to this post

    Hi, a couple more related queries (please advise if these are better posted as separate threads, or as a support ticket):

    • Is it possible to change the HeaderText of the automatically generated checked column? I note it doesn't fire the ColumnCreating event, where I'd normally change this. 
    • Is it possible to detect if a double-click occurs below the last row in the RadListView?
  7. Dess
    Admin
    Dess avatar
    2107 posts

    Posted 07 Feb Link to this post

    Hello Kevin, 

    Thank you for writing back. 

    In order to change the header text of a certain column, you can set the HeaderText property of the desired column as it is demonstrated below:
    this.radListView1.Columns[1].HeaderText = "my header text";

    As to the question regarding the DoubleClick event, note that you can get the DetailListViewDataCellElement and determine if the associated data item is the last one. Here is a sample code snippet:
    private void radListView1_DoubleClick(object sender, EventArgs e)
    {
        MouseEventArgs args = e as MouseEventArgs;
        if (args != null)
        {
            DetailListViewDataCellElement elementUnderMouse = this.radListView1.ElementTree.GetElementAtPoint(args.Location) as DetailListViewDataCellElement;
            if (elementUnderMouse != null && elementUnderMouse.Row == this.radListView1.Items.Last())
            {
                this.radListView1.BeginEdit();
            }
        }
    }

    I hope this information helps. If you have any additional questions, please let me know. 

    Regards,
    Dess
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  8. KKL
    KKL avatar
    15 posts
    Member since:
    Nov 2016

    Posted 07 Feb in reply to Dess Link to this post

    Thank you, my second question is answered! The first one though: 

    Is it possible to change the HeaderText of the automatically generated checked column? This is the column created when CheckedMember is set. This column doesn't appear to be part of the radListView1.Columns list. 

  9. Dess
    Admin
    Dess avatar
    2107 posts

    Posted 07 Feb Link to this post

    Hello Kevin, 

    Thank you for writing back. 

    Indeed, the checkbox is displayed before the other cells and it doesn't have a particular column for it. You actually see the DetailListViewElement in the upper left corner above the checkboxes. If you need to have a checkbox column with a header text, it is appropriate to use a RadGridView which offers a GridViewCheckBoxColumn for such cases. Additional information is available here: http://docs.telerik.com/devtools/winforms/gridview/columns/column-types/gridviewcheckboxcolumn

    I hope this information helps. If you have any additional questions, please let me know. 

    Regards,
    Dess
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top