Click here to Skip to main content
15,901,505 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
value was either Too large to too small for list error for combobox i tried converting it to int64.

Int64 k = Convert.ToInt64(textBoxQuantity.Text);
Int64 j = Convert.ToInt64(cbxListSN.Text);

for (Int64 i = 0; i < k; i++)
{
SerialListBox.Items.Add(j + i + 1);
}

but its not working. i have 20 digits.

i need to convert my combo box and listbox to bytes so it can take more than 20 characters.

currently its only taking lass than 10 characters.
but i want to put more than 20 character.
Posted

1 solution

Hi,
I think you should set your value to combobox DisplayMember property not ValueMember.
So Try like this;

C#
DataTable dtList = new DataTable();
dtList.Columns.Add("Value");
dtList.Columns.Add("Text");

Int64 k = Convert.ToInt64(textBoxQuantity.Text);
Int64 j = Convert.ToInt64(cbxListSN.Text);

for (Int64 i = 0; i < k; i++)
{
DataRow dr = dtList.NewRow();
dr["Value"] = i;
dr["Text"] = j + i + 1;
dtList.Rows.Add(dr);
} 
SerialListBox.DataSource = dtList;
 
Share this answer
 
Comments
ByakuyaKuchiki 4-Mar-13 1:25am    
i tried this it not working.
i want to take value from combobox which is about 20 character and quantity from textbox and show increment sequence on list box.
it is working the problem is that it giving me error of too ling or too short list.
this error is comming becox my combo box is 20 characters.
i want to convert my combobox to bytes or somthing which will allow me to work with 20 character.
Ibrahim Uylas 4-Mar-13 2:01am    
Did you set DisplayMember and ValueMember?
like:
SerialListBox.DisplayMember = "Text";
SerialListBox.ValueMember = "Value";
ByakuyaKuchiki 4-Mar-13 2:18am    
yes.
i did.

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