I have been using a radlistbox in my form and trying to display image against each record. the problem is that it takes around 7 seconds to display around 2000 records, which is very slow. in one of the article i have read that RadListBox take less than one second to load 2000 records
I am using following lineof code to add the text and image to list.
foreach (string strConnectedItem in arrTemp)
{
RadListBoxItem item = new RadListBoxItem();
if (arrConnectedDLD.Count != 0 && arrConnectedDLD.Contains(strConnectedItem))
{
//arrConnectedDLDinMasterFile.Add(strConnectedItem);
////RadListBoxItem item = new RadListBoxItem();
item.Text = strConnectedItem;
item.Image = imageListLB.Images[1]; ;
item.Value = strConnectedItem;
arrDLDList.Add(strConnectedItem +
"." + "1");
radLbDLD.Items.Add(item);
radCbDLD.Items.Add(
new RadComboBoxItem(strConnectedItem, strConnectedItem));
}
else
{
// arrNotConnectedDLD.Add(strConnectedItem);
//RadListBoxItem item = new RadListBoxItem();
item.Text = strConnectedItem;
item.Image = imageListLB.Images[0];
item.Value = strConnectedItem;
arrDLDList.Add(strConnectedItem +
"." + "0");
radLbDLD.Items.Add(item);
radCbDLD.Items.Add(
new RadComboBoxItem(strConnectedItem, strConnectedItem));
}
item.BorderThickness =
new System.Windows.Forms.Padding(1);
item.CanFocus =
true;
//item.Margin = new System.Windows.Forms.Padding(15, 0, 0, 0);
item.TextImageRelation = System.Windows.Forms.
TextImageRelation.ImageBeforeText;
item.TextSeparatorVisibility = Telerik.WinControls.
ElementVisibility.Visible;
}
if is remove the above code and instead use
radLbDLD.DataSource = arrDLDList;
then the loading time is reduced but inage is not displayed.
as per my understanding the most of the time is taken in adding item to list on by one.
is there any way by which I can avoid this looping.
Also I could not find any property in RadListBox equivalent to ListBox.Items[n].ImageIndex in .net controls
please suggest what can be done to improve the performance.
Thanks & Regards,
Vijay Chowdhary