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

problem with listview orientation

1 Answer 256 Views
ListView
This is a migrated thread and some comments may be shown as answers.
David T.
Top achievements
Rank 1
David T. asked on 11 Jul 2013, 04:08 PM
 
this is the demo snipped of code that you provide in winforms Q2 2013 demo for listview -> custom settings. The orientation works fine in the demo app but I have the same snipped of code as the demo app.  I've debugged this multiple times trying to figure out why the orientation is always vertical but there is no clear reason for it at the moment.  

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.QuickStart.WinControls;
 
namespace Telerik.Examples.WinControls.ListView.CustomItems
{
    public partial class Form1 : ListViewExamplesControl
    {
        public Form1()
        {
            InitializeComponent();
 
            this.radListView1.ItemSize = new Size(200, 300);
            this.radListView1.AllowArbitraryItemHeight = true;
            this.radListView1.ItemSpacing = 10;
            this.radListView1.EnableKineticScrolling = true;
 
            this.radListView1.ListViewElement.ViewElement.ViewElement.Margin = new Padding(0, 10, 0, 10);
            this.radListView1.ListViewElement.ViewElement.Orientation = Orientation.Horizontal;
        }
    }
}

This is my code, it is very simple right now because I am still working on the figuring out the functionality 
of RadListView.  I've hard coded the orientation multiple times and printed it out in MessageBox but each time
MessageBox prints out vertical, for each of the 12 items in the Imagelist.  I was hoping you could explain why this
happens all of the time and a way to fix this.  Thank you for your time in this matter.  

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
using System.IO;
using System.Linq;
using Telerik.WinControls.Layouts;
using Telerik.WinControls.UI;
 
namespace testingImageViewer
{
    public partial class RadForm1 : Telerik.WinControls.UI.RadForm
    {
        private int intImageHeight = 0;
        private int intImageWidth = 0;
        private string strFilePath = "";
        StackLayoutPanel stackLayout;
        LightVisualElement imageElement;
 
        Image myImage;
        public RadForm1()
        {
            InitializeComponent();
            radListview.ItemSize = new Size(200, 300);  
            radListview.AllowArbitraryItemHeight = true;
            radListview.EnableKineticScrolling = true;
            radListview.ListViewElement.ViewElement.Orientation = Orientation.Horizontal;
            MessageBox.Show(radListview.ListViewElement.ViewElement.Orientation.ToString());
        }
 
        public void fillImageList()
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                myImage = Image.FromFile(ofd.FileName);
                strFilePath = ofd.FileName;
            }
            else
            {
                MessageBox.Show("open dialog didn't open");
            }
        }
 
        private void RadForm1_Load(object sender, EventArgs e)
        {
            fillImageList();
            imagelistPictures.Images.Add(myImage);            
            showImages();
        }
 
        private void showImages()
        {
            if (imagelistPictures.Images.Empty)
            {
                MessageBox.Show("list image preview is empty");
            }
            else
            {
                for (int i = 0; i < imagelistPictures.Images.Count; i++)
                {
                    if (imagelistPictures.Images[i] != null)
                    {
                        // radListview.Items.Add(listImagePreview.Images[i]);
                        //intImageWidth = listImagePreview.Images[i].Width;
                        //intImageHeight = listImagePreview.Images[i].Height;
                        // pictureBox1.Image = listImagePreview.Images[i];  // adds it to picture box, adjust height/width
 
 
                        // show the image
                        // radListview.Height = imagelistPictures.Images[i].Height;
                        // radListview.Width = imagelistPictures.Images[i].Width;
 
                        ListViewDataItem lvdi = new ListViewDataItem("Go Hokies");
                        lvdi.Image = imagelistPictures.Images[i];
                        lvdi.ImageAlignment = System.Drawing.ContentAlignment.MiddleCenter;
                        //lvdi.Size.
 
                        radListview.Items.Add(lvdi);
 
                        radListview.ListViewElement.ViewElement.Orientation = Orientation.Horizontal;
                        MessageBox.Show(radListview.ListViewElement.ViewElement.Orientation.ToString());
                    }
                    else
                    {
                        MessageBox.Show("contents of list are null, break");
                        break;
                    }
                }
            }
        }
 
 
 
    }
}

      

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 16 Jul 2013, 09:04 AM
Hi David,

Thank you for writing.

The desired Orientation is not supported in the default ViewType of RadListView. To set the orientation you should use IconView as in the example mentioned:
radListview.ViewType = ListViewType.IconsView;

More information about the different views the control supports, please have a look at the following article: http://www.telerik.com/help/winforms/listview-views.html.

I hope this helps.
 
Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ListView
Asked by
David T.
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or