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

Moving away from ObjectListView

8 Answers 692 Views
ListView
This is a migrated thread and some comments may be shown as answers.
KKL
Top achievements
Rank 1
KKL asked on 08 Jan 2017, 02:08 AM

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? 

8 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 10 Jan 2017, 08:32 AM
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 . 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.
0
KKL
Top achievements
Rank 1
answered on 10 Jan 2017, 10:27 AM
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?
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 10 Jan 2017, 11:13 AM
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.
0
KKL
Top achievements
Rank 1
answered on 14 Jan 2017, 11:29 AM
Many thanks for you fast response!
0
KKL
Top achievements
Rank 1
answered on 05 Feb 2017, 11:44 AM

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?
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 07 Feb 2017, 09:28 AM
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.
0
KKL
Top achievements
Rank 1
answered on 07 Feb 2017, 10:52 AM

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. 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 07 Feb 2017, 12:15 PM
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.
Tags
ListView
Asked by
KKL
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
KKL
Top achievements
Rank 1
Share this question
or