在现有的stringcollection中添加另一个字符串 [英] adding another string to existing stringcollection

查看:62
本文介绍了在现有的stringcollection中添加另一个字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



我有这个代码用于通过displayindex,width和visibility创建我的datagridview的stringCollection dg,它工作得很好,我将它保存到Properties。设置,但我需要添加另一个字符串或更好说我需要添加第5个字符串,这将是我创建的每个stringCollection的模板的ID,(我有多个用户)



基本上我的xml文件看起来像这样

Hello

I have this code for creating stringCollection of my datagridview called dg by displayindex, width and visibility and it's working great,I am saving it to Properties.Settings , but I need to add another string or better said I need to add 5th string, which will be ID of template of each stringCollection I am creating, (I have multiple users)

basically I my xml file look like this

00,100,False,0
01,100,False,1
.....



我想加5号


and I want to add 5th

00,100,False,0,1
01,100,False,1,1
....




00,100,False,0,2
01,100,False,1,2
....



所以当我用第5个字符串调用stringCollection时,我只得到第5个字符串的stringCollection




so when I call stringCollection by that 5th string I get only stringCollection with that string in 5th

StringCollection stringCollection = new StringCollection();
int i = 0;
foreach (DataGridViewColumn column in this.dg.Columns)
{
    stringCollection.Add(string.Format(
        "{0},{1},{2},{3}",
        column.DisplayIndex.ToString("D2"),
        column.Width,
        column.Visible,
        i++));
}
Settings.Default.columns = StringCollection;
Settings.Default.Save();

推荐答案

也许你的string.Format需要更新。



类似于:

Maybe your string.Format needs to be updated.

Something like:
stringCollection.Add(string.Format(
    "{0},{1},{2},{3}, {4}",
    column.DisplayIndex.ToString("D2"),
    column.Width,
    column.Visible,
    i++,
    ID)
);





我不知道,因为我几乎不明白你的问题。



I don't know because I barely understood your question.


这篇关于在现有的stringcollection中添加另一个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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