I've a Dictionary
Dictionary<string, List<string>> SampleDict = new Dictionary<string, List<string>>();
I need to fill a listView with the contents of the Dictionary
For example the "SampleDict" contains
One A
B
C
Two D
E
F
The listView should be filled like
S.No Item SubItem
1 One A,B,C
2 Two D,E,F
Now i'm using for loop for this method
like
List<String> TepmList=new List<String>(SampleDict.Keys);
for(int i=0;i<TepmList.Count;i++)
{
listView1.Items.Add((i+1).ToString());
listView1.Items[i].SubItems.Add(TepmList[i]);
List<String>Lst=SampleDict[TepmList[i]])
String Str="";
int K=0;
for(int j=0;j<Lst.Count;j++)
{
string s=Lst[j];
k++;
if(k==1)
Str=s;
else
Str=","+Str;
}
listView1.Items[i].SubItems.Add(Str);
}
is there any other way to do this like data binding ?
Thanks in advance.