Hi Guys......
I am new to this website and found it really good when it comes to problem solving and concept clearing...
I am facing a problem..
I have used multiselect option of the openfiledialog, but I am unable to write the result of this in a RichTextBox or a ComboBox or a ListBox or a TreeView...
- What I want to do exactly is that any of the above mentioned controls show the FileNames of the files that have been selected by the user in the openfiledialog..
Please Help !!!
Chitkaran Singh


AlanRank #669 · 3.6K reputationPosted Nov 7, 2007, 3:59 AM EST
Assuming you've set the RichTextBox's Multiline property to true, then the code to list the file names within it would be something like this:
DialogResult dr = openFileDialog1.ShowDialog();
if (dr == DialogResult.OK)
{
richTextBox1.Text = String.Join("\r\n", openFileDialog1.FileNames);
}
Chitkaran SinghRank #3,100 · 462 reputationPosted Nov 11, 2007, 5:23 AM EST
private
void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e){
pictureBox1.ImageLocation = treeView1.SelectedNode.Nodes.ToString();
//MessageBox.Show(treeView1.SelectedNode.Nodes.ToString());}
Gives an exception..
{"Object reference not set to an instance of an object."}
AlanRank #669 · 3.6K reputationPosted Nov 11, 2007, 6:22 AM EST
Perhaps the selected node has no child nodes and hence its Nodes property is null?
But, even if it has, then you won't get anything meaningful from its ToString() method - just the name of the type which will be System.Windows.Forms.TreeNodeCollection or something like that.
If the node which has been clicked has a label which represents the path of the image you want to place in the picturebox, then I'd try:
pictureBox1.ImageLocation = e.Node.Text;
Chitkaran SinghRank #3,100 · 462 reputationPosted Nov 11, 2007, 8:16 AM EST
Oh thats really worked... Thanx Allan..
Just a simple think I wanna ask...
When I click on the node and place the corresponding image in the pictire box, it goes beyond the limits of the picture box..
So is there a way with which I can specity that irrespective of the actual size of the image, it stays in the limits of the pictore box, or the size that I specify.. ???
AlanRank #669 · 3.6K reputationPosted Nov 11, 2007, 8:24 AM EST
Chitkaran SinghRank #3,100 · 462 reputationPosted Nov 11, 2007, 8:38 AM EST
Hey Alan...
Thanks for showing me the way Sir,,
Actually, the zoom propety worked for me in this case,,, But ur the one who showed me the way...
Thanks again Sir.