Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have some Fetal Vessel names in a list called "ls". I need to populate those values in an excel sheet and create hyperlink for each of them.
These Fetal vessel names are loaded dynamically to the list for each patient.
My problem is when i click on any vessel's hyperlink, the last hyperlink is opening.
am using windows form.
here is my code -

C#
//------------Creating drop down for the values of list--------------
    string list = string.Join(",", ls.ToArray());
    range.Validation.Delete();
    range.Validation.Add(XlDVType.xlValidateList, XlDVAlertStyle.xlValidAlertInformation, XlFormattConditionOperator.xlBetween, list, Type.Missing);
    range.Validation.IgnoreBlank = true;
    range.Validation.InCellDropdown = true; 
//---------------looping through each value and creating hyperlink----------
    foreach (object lst in ls)
    {
        Microsoft.Office.Interop.Excel.Hyperlink hyperlink = (Microsoft.Office.Interop.Excel.Hyperlink)range.Hyperlinks.Add(range, "P:\\"+ PID.Text.ToString() + "\\"+ lst.ToString() + ".avi",Type.Missing, Type.Missing, "" + lst.ToString() + "");
    }
Posted
Updated 11-May-11 1:26am
v2

I think macro will do needful to you.
 
Share this answer
 
you are not updating the range in foreach loop. so if there are 10 items in ls the same range will get updated 10 times hence the 10th (i.e. last) updation will take effect.

thanks,
Hemant
 
Share this answer
 
v2
Comments
Deepurs 13-May-11 1:30am    
how do i update the range in foreach loop??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900