Windows Develop Bookmark and Share   
 index > Windows Forms Designer > [C#]Adding files to CheckedListBox
 

[C#]Adding files to CheckedListBox

Hi all Smile

Is it possible to have a CheckedListBox which contains as items some files?

For ex.:

myDocument.pdf
myDocument.doc
myDocument.xls

If not, how can i obtain something like the above?

(without using of openFileDialog .... )

Many thx in advance.

RaouL.
Raoul_BennetH  Friday, May 11, 2007 4:03 PM


Code Snippet

void Form3_Load(object sender, EventArgs e)

{

this.checkedListBox1.Items.AddRange(System.IO.Directory.GetFiles(@"C:\", "*.*"));

this.checkedListBox1.ItemCheck += new ItemCheckEventHandler(checkedListBox1_ItemCheck);

}

void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)

{

Process.Start(this.checkedListBox1.Items[e.Index].ToString());

}

Do you mean to add the filenames as item of the CheckedListBox, click on which to open the file?

Zhi-Xin Ye  Friday, May 18, 2007 3:18 AM
Zhi-Xin Ye - MSFT wrote:
Do you mean to add the filenames as item of the CheckedListBox, click on which to open the file?


Yes Smile
Raoul_BennetH  Friday, May 18, 2007 1:36 PM

You could try this:

Code Snippet

checkedListBox1.Items.AddRange(System.IO.Directory.GetFiles(@"C:\", "*.*"));

Christopher Payne  Friday, May 18, 2007 11:31 PM


Code Snippet

void Form3_Load(object sender, EventArgs e)

{

this.checkedListBox1.Items.AddRange(System.IO.Directory.GetFiles(@"C:\", "*.*"));

this.checkedListBox1.ItemCheck += new ItemCheckEventHandler(checkedListBox1_ItemCheck);

}

void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)

{

Process.Start(this.checkedListBox1.Items[e.Index].ToString());

}

Great! Works perfectly!

Sincerely thank you a billion!!

RaouL.

Raoul_BennetH  Monday, May 21, 2007 11:54 AM

You can use google to search for other answers

Custom Search

More Threads

• ToolStripControlHost Constructor on type 'System.Windows.Forms.ToolStripControlHost' not found. Issue
• Tracking text entry position
• Operation is not valid due to the current state of the object.
• statusbar panels question
• error creating the inherited form
• Z-axys adjustment for controls in a usercontrol
• Form Sizes in different resolution
• User Control - Get Parent size
• Are u Expert of WinForms? Run Time Designing & MSI Creation... must read my message...
• LinkLabel