Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
error:can't convert type base DevExpress.XtraEditorslist box controls.selected items collections to system.IO.Directoryinfo


am using devex controls
plz solve this error any one
Posted
Comments
Mario Majčica 9-Feb-12 5:49am    
What's the context? Did you tried contacting DevX support? They have awesome support team ;)

Cheers
rockpune 9-Feb-12 6:13am    
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using DevExpress.XtraEditors;

namespace browserlist
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

foreach (DriveInfo d1 in DriveInfo.GetDrives())
drivelist.Items.Add(d1);
}

private void drivelist_SelectedIndexChanged(object sender, EventArgs e)
{
folderlist.Items.Clear();
try
{
DriveInfo drive = (DriveInfo)drivelist.SelectedItem;
foreach (DirectoryInfo driveinfo in drive.RootDirectory.GetDirectories())
folderlist.Items.Add(driveinfo);

}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void folderlist_SelectedIndexChanged(object sender, EventArgs e)
{
fileslist.Items.Clear();
DirectoryInfo dir = (DirectoryInfo)folderlist.SelectedItems;
foreach (FileInfo f1 in dir.GetFiles())
fileslist.Items.Add(f1);
}
}
}

1 solution

Post your code inside your question, not as a comment. Also, the error means what it says. Given the vast difference between the two types you mention, I suspect you're doing something insane in your code. Use your debugger. Read the code. Check the methods you're calling and their parameter types and return types. When the IDE tells you what line is blowing up, read that line, and TELL US WHAT IT IS if you need to ask for help.

I'd say this is the error:

DirectoryInfo dir = (DirectoryInfo)folderlist.SelectedItems;

Your selected items may be a collection of DirectoryInfo items, but they are a collection, not one object. The SelectedItem property might work here.

This is basic coding 101, I would suggest it's insane you're using paid for tools when you have no idea about basic programming. You should buy some basic books and read them.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900