a way to execute the file on list view by doubleclick
-
Hello everyone!!! Me and this problem again!!! =D This is my code:
private void lvFiles_SelectedIndexChanged(object sender, System.EventArgs e)
{
ShellLib.ShellExecute shellExecute = new ShellLib.ShellExecute();
shellExecute.Verb = ShellLib.ShellExecute.OpenFile;
shellExecute.Path = @"F:\Painel de Controle ETECH\Projetos ETECH\{0}\80010005.dwg";
shellExecute.Execute();}
It works BUT open only the file written in the
shellExecute.Path
statement I need to find a way to execute a selected file on the list view... Well I´d many ideas and none worked.. I was thinking to put the selected file on a string and then to put this string on the end of the path statement but I didn´t figure out how to do it and mainly how to put the file name on a string when I select it on the list view control! Could anyone help me?? I´m very desperate!!!! best wishes for all!!! -
Hello everyone!!! Me and this problem again!!! =D This is my code:
private void lvFiles_SelectedIndexChanged(object sender, System.EventArgs e)
{
ShellLib.ShellExecute shellExecute = new ShellLib.ShellExecute();
shellExecute.Verb = ShellLib.ShellExecute.OpenFile;
shellExecute.Path = @"F:\Painel de Controle ETECH\Projetos ETECH\{0}\80010005.dwg";
shellExecute.Execute();}
It works BUT open only the file written in the
shellExecute.Path
statement I need to find a way to execute a selected file on the list view... Well I´d many ideas and none worked.. I was thinking to put the selected file on a string and then to put this string on the end of the path statement but I didn´t figure out how to do it and mainly how to put the file name on a string when I select it on the list view control! Could anyone help me?? I´m very desperate!!!! best wishes for all!!!Gianpaolo Barci wrote:
I was thinking to put the selected file on a string and then to put this string on the end of the path statement
if you mean
shellExecute.Path = someString;
yes that would be the thing to do.Gianpaolo Barci wrote:
but I didn´t figure out how to do it
why not? That is a programming 101 concept. What is your programming background?
led mike
-
Gianpaolo Barci wrote:
I was thinking to put the selected file on a string and then to put this string on the end of the path statement
if you mean
shellExecute.Path = someString;
yes that would be the thing to do.Gianpaolo Barci wrote:
but I didn´t figure out how to do it
why not? That is a programming 101 concept. What is your programming background?
led mike
shellExecute.Path = someString;
andsomeString
represents the path to the file I selected on the listView control. Yes, It means that I´m in the right way now. The problem is right here... select the file in the ListView and put it´s path and it´s name on a string... I´m a totally dummy with event oriented programming. My knowledge is structured C, Data Structures on C.. I can do an entire B-Tree using C but I can´t implement a simple event.. oh shame on me... =( -
Hello everyone!!! Me and this problem again!!! =D This is my code:
private void lvFiles_SelectedIndexChanged(object sender, System.EventArgs e)
{
ShellLib.ShellExecute shellExecute = new ShellLib.ShellExecute();
shellExecute.Verb = ShellLib.ShellExecute.OpenFile;
shellExecute.Path = @"F:\Painel de Controle ETECH\Projetos ETECH\{0}\80010005.dwg";
shellExecute.Execute();}
It works BUT open only the file written in the
shellExecute.Path
statement I need to find a way to execute a selected file on the list view... Well I´d many ideas and none worked.. I was thinking to put the selected file on a string and then to put this string on the end of the path statement but I didn´t figure out how to do it and mainly how to put the file name on a string when I select it on the list view control! Could anyone help me?? I´m very desperate!!!! best wishes for all!!!How are you populating your listview with the files? Where is the file information coming from? Each ListViewItem has a Tag property that holds an object. Save your full path to the file in there. When you need it, just cast that ListViewItem's Tag to a string and you've got the file's path. Alternatively, create a custom ListViewItem that has a Path property, then you can cast the entire item to your class and access the Path property.
public class ListViewItemWithPath : ListViewItem
{
public ListViewItemWithPath(string fileName, string path)
{
Text = fileName;
m_Path = path;
}
private string m_Path;
public string Path
{
get { return m_Path; }
set { m_Path = value; }
}
}Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) -
How are you populating your listview with the files? Where is the file information coming from? Each ListViewItem has a Tag property that holds an object. Save your full path to the file in there. When you need it, just cast that ListViewItem's Tag to a string and you've got the file's path. Alternatively, create a custom ListViewItem that has a Path property, then you can cast the entire item to your class and access the Path property.
public class ListViewItemWithPath : ListViewItem
{
public ListViewItemWithPath(string fileName, string path)
{
Text = fileName;
m_Path = path;
}
private string m_Path;
public string Path
{
get { return m_Path; }
set { m_Path = value; }
}
}Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)Dave I got your point!!! Working on it right now!!! Thanks
-
How are you populating your listview with the files? Where is the file information coming from? Each ListViewItem has a Tag property that holds an object. Save your full path to the file in there. When you need it, just cast that ListViewItem's Tag to a string and you've got the file's path. Alternatively, create a custom ListViewItem that has a Path property, then you can cast the entire item to your class and access the Path property.
public class ListViewItemWithPath : ListViewItem
{
public ListViewItemWithPath(string fileName, string path)
{
Text = fileName;
m_Path = path;
}
private string m_Path;
public string Path
{
get { return m_Path; }
set { m_Path = value; }
}
}Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)I did this!
private void lvFiles_SelectedIndexChanged(object sender, System.EventArgs e)
{
string filePath = lvFiles.SelectedItems.ToString();
ShellLib.ShellExecute shellExecute = new ShellLib.ShellExecute();
shellExecute.Verb = ShellLib.ShellExecute.OpenFile;
shellExecute.Path = @"F:\\Painel de Controle ETECH\\Projetos ETECH" + filePath;
shellExecute.Execute();}
Am I close??
-
I did this!
private void lvFiles_SelectedIndexChanged(object sender, System.EventArgs e)
{
string filePath = lvFiles.SelectedItems.ToString();
ShellLib.ShellExecute shellExecute = new ShellLib.ShellExecute();
shellExecute.Verb = ShellLib.ShellExecute.OpenFile;
shellExecute.Path = @"F:\\Painel de Controle ETECH\\Projetos ETECH" + filePath;
shellExecute.Execute();}
Am I close??
Did you sort it?
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)