为列表框中的每个已添加项添加前缀 [英] Add Prefix for each Added item in listbox

查看:120
本文介绍了为列表框中的每个已添加项添加前缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文本框,一个有值递增,另一个给出增量的数量,增量值显示在列表框上

i想要当值插入列表框时每个值必须有ERT 带有它的信件。



i尝试跟随,但它影响了我的系列递增



decimal j = Convert.ToDecimal(textBoxlist.Text);



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



if(textBoxlist.Text.Length> 15)

{



for(int i = 0; i< k ; i ++)

{

SerialListBox.Items.Add(ERT+ j + i + 1);

}



我想在每个列表框项目中添加ERT的前缀。

i have two text box one have value to increment and other one gives the amount to increment with and increment value is showen on listbox
i want when value is inserted to listbox each value must have "ERT" letters with it.

i tried following but it is effecting my incrementing of series

decimal j = Convert.ToDecimal(textBoxlist.Text);

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

if (textBoxlist.Text.Length >15)
{

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

simply i want to add prefix of ERT to each list box item.

推荐答案

这是ERT+ j + i + 1 作为字符串值的母鸡你最终得到了





当J = 10且I = 0时ERT1001



来修复它改变这一行



It is taking the "ERT" + j + i + 1 as a string value hence you end up with


ERT1001 when J = 10 and I = 0

to fix it change this line

SerialListBox.Items.Add("ERT"+j + i + 1);





to





to

SerialListBox.Items.Add("ERT"+j + (i + 1));





如果我错过了你的问题,请通过解释告诉我它进一步。



If I have missed your problem completley please let me know by explaining it further.


这篇关于为列表框中的每个已添加项添加前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆