المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Index was out of range. Must be non-negative and less than the size of the collection while adding combo box control to listview control



C# Programming
07-02-2009, 08:30 AM
I am trying to add combo box control as subitem for 1st column 1st row in listview control. Below is the code:
1.ComboBox cmb = new ComboBox();
2.cmb.Items.Add("Yes");
3.cmb.Items.Add("No");
4.cmb.DropDownStyle = ComboBoxStyle.DropDownList;
5.this.ListViewInkers.Items[i].SubItems[iCol].Control = cmb;

But i am getting below exception for 5th line.
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll

Additional information: Index was out of range. Must be non-negative and less than the size of the collection.

Thanks in advance.