Question

I need loading some files name according to user selection from combo box and run when click on file name .

for example :

combobox list =>

  • electerical
  • physical

When select electrical load excel files from electrical folder and select physical load excel files from physical folder and when user click on file name run file

   private void cmbMapType_SelectedIndexChanged(object sender, EventArgs e)
   {
    cmpMapSearchFolder = Application.StartupPath + "\\mv\\" + vo + "\\compact\\" + cmbMapType.SelectedItem.ToString();
            }

            bool cmpMapOk = false;
            foreach (string directoryfilename in Directory.GetFiles(cmpMapSearchFolder, "*.xlsx"))
            {
                cmpMapOk = true;

            }
}

What tool do I do this? How?
with link label?

Was it helpful?

Solution

Look populate your combox with a list of string in the Load event of your Form

string[] list = {"","electrical","physical"};
cmbMapType.DataSource = list;

and implement the Event named SelectedIndexChanged of the ComboBox control, inside this method store the links of the files. Well, later you can do many things, one of them is store in a ListBox those links, and implement the SelectedValueChanged, inside this method launch a new process to open the excel file:

Process process = new Process();
process.StartInfo.FileName = @"your link to your excel file";
process.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
process.Start();

I repeat there is a lot of ways to achieve this. Hope it helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top