Thread: C# Question
View Single Post
Old 03-18-2009, 07:59 AM   #5 (permalink)
office politics
office politics's Avatar
 
It's all just 1s and 0s

Join Date: Jan 2004

Location: in the lab

Posts: 4,425

office politics will become famous soon enough

Default Re: C# Question

you'll want to create a listviewitem. add any sub items. and then add the lvitem to the list view. set the list box in details mode to show multiple columns.

Someone else might have a better way, but this is how i tackled it for a recent project.

I wanted to show a list of files in the list box. column 1 is a counter, column 2 is the url, colmuns three is the status. here's the code

Code:
do
            {
                servPath = FolderURL.Peek().ToString();
                DirList = FtpDirList(FolderURL.Pop());
                Match fi;
                List<string> Fname = new List<string>();
                try
                {
                    for (int i = 0; i < DirList.Length; i++)
                    {
                        fi = FileInfo(DirList[i]);
                        ListViewItem item = new ListViewItem((lvFiles.Items.Count + 1).ToString());
                        if (fi.Groups["dir"].Value.Equals("<DIR>"))
                        {
                            item.SubItems.Add(servPath + "/" + fi.Groups["name"].Value + "/");
                            FolderURL.Push(servPath + "/" + fi.Groups["name"].Value);
                        }
                        else
                            item.SubItems.Add(servPath + "/" + fi.Groups["name"].Value);
                        item.SubItems.Add("FTP");
                        lvFiles.Items.Add(item);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            } while (FolderURL.Count > 0);

office politics is offline