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

Winform Telerik RadListView populates data but text is not visible

3 Answers 452 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Isai
Top achievements
Rank 1
Isai asked on 17 Sep 2018, 01:15 AM

Hello, I have the following code at the bottom which should load data automatically into the RadListView at form load. However, the text is not visible in the RadListView. I can see the exact number of rows being returned from the SQL database into the RadListView. why is the text not visible?

 

Thank you for your help in advance! :)

 

 

private void MemberUC_Load(object sender, EventArgs e)
        {
            //fill main panel
            this.Dock = DockStyle.Fill;
           
            using (SqlConnection con = new SqlConnection(*connection string string goes here*))
            {
                con.Open();
                cmd = new SqlCommand("SELECT FirstName, MiddleName, LastName, MemberType FROM dbo.MemberInformation");
                cmd.Connection = con;
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    ListViewItem item = new ListViewItem();
                    item.SubItems.Add(dr["FirstName"].ToString());
                    item.SubItems.Add(dr["MiddleName"].ToString());
                    item.SubItems.Add(dr["LastName"].ToString());
                    item.SubItems.Add(dr["MemberType"].ToString());
                    memberDetailsLV.Items.Add(item);
                }
            }
        }

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 18 Sep 2018, 07:29 AM
Hello, Isai,  

When in DetailsView, RadListView displays columns. The columns are stored in a collection that is accessible through the Columns property. Columns can be added to RadListView using one of the three overloads of the Add method. Each column must have a unique name because columns are distinguished by their Name property. You can set cell values to the items of RadListView using their indexers. The keys can be either the index of the column, the name of the column, or the column itself.

You can refer to the following help article demonstrating how to add columns and specify the value for each cell: https://docs.telerik.com/devtools/winforms/listview/populating-with-data/unbound-mode
 
I hope this information helps.

Regards,
Dess
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Isai
Top achievements
Rank 1
answered on 22 Sep 2018, 03:57 PM

Hello Dess,

 

Thank you so much for your help! The link you sent shined a light on where I was having the problem.

Turns out that I was also missing the 'using Telerik.WinControls.UI' namespace which would not let me use ListViewDataItem item = new ListViewDataItem();

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 Sep 2018, 11:09 AM
Hello, Isai,  
 
I am glad that the suggested documentation was useful for achieving your requirement.

You can try the Telerik UI for WinForms suite, which you can learn more about via the product page and comes with a 30-day free trial giving you some time to explore the toolkit and consider using it for your current or upcoming WinForms development.

Regards,
Dess
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
ListView
Asked by
Isai
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Isai
Top achievements
Rank 1
Share this question
or