如何更改checkboxcombobox项目逗号连接分隔符/分隔符 [英] How to change checkboxcombobox items comma concatenate delimiter / separator

查看:479
本文介绍了如何更改checkboxcombobox项目逗号连接分隔符/分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CheckBoxComboBox项[逗号',']连接分隔符/分隔符。



我用健康提供者的名字填充CheckBoxComboBox,这些名称保存并显示在此格式LastName,FirstName(不带引号)但是,当选择多个提供程序时,项目分隔符也是逗号,这会产生解析问题,因为已在提供程序的名称中使用逗号。有没有办法将默认的逗号分隔符更改为分号';'管道'|'或其他任何东西?



我想我可以更改代码,但在项目的哪个部分我可以进行此更改的代码?



谢谢。



我尝试了什么:



查找项目分隔符/分隔符属性,在整个项目中搜索分隔符, Concatenator,Delimiter','等等但是找不到任何东西。在哪里?

解决方案

另一个我刚刚孤独的自我解决了:-)



这是解决方案;更改此行代码上的逗号

[ListText + = string.IsNullOrEmpty(ListText)? Item.Text:String.Format(,{0},Item.Text);]用于您想要使用的任何字符,或为其添加属性,以便您可以使其动态化。



CheckBoxComboBox.cs



///< summary>

///构建一个CSV字符串选择的项目。

///

内部字符串GetCSVText(bool skipFirstItem)

{

string ListText = String .Empty;

int StartIndex =

DropDownStyle == ComboBoxStyle.DropDownList

&& DataSource == null

&& skipFirstItem

? 1

:0;



for(int Index = StartIndex; Index< = _

CheckBoxComboBoxListControl。 Items.Count - 1; Index ++)

{

CheckBoxComboBoxItem Item = _CheckBoxComboBoxListControl.Items [Index];

if(Item.Checked)

ListText + = string.IsNullOrEmpty(ListText)? Item.Text:String.Format(,{0},Item.Text);

}

返回ListText;

}

CheckBoxComboBox items [comma ','] concatenate delimiter / separator.

I am populating the CheckBoxComboBox with health provider's names, these names are saved and displayed in this format "LastName, FirstName" (without the quotes) however when selecting more than one provider the item delimiter is also a comma, this creates a parsing problem because a comma is already used in the Provider's name. Is there a way to change the default comma delimiter to a semicolon ';' a pipe '|' or anything else?

I guess I could change the code for that, but where in the project is this part of the code where I can make this change?

Thank you.

What I have tried:

Looked for an items Delimiter/Separator property, searched on the whole project for either Separator, "Concatenator", Delimiter ',' etc. But could not find any. Where is it?

解决方案

Well another one I just solved all by my lonely self :-)

Here is the solution; change the comma on this line of code
[ListText += string.IsNullOrEmpty(ListText) ? Item.Text : String.Format(", {0}", Item.Text);] for whatever character you want to use, or add Property for it so you can make this dynamic.

CheckBoxComboBox.cs

/// <summary>
/// Builds a CSV string of the items selected.
///
internal string GetCSVText(bool skipFirstItem)
{
string ListText = String.Empty;
int StartIndex =
DropDownStyle == ComboBoxStyle.DropDownList
&& DataSource == null
&& skipFirstItem
? 1
: 0;

for (int Index = StartIndex; Index <=_
CheckBoxComboBoxListControl.Items.Count - 1; Index++)
{
CheckBoxComboBoxItem Item = _CheckBoxComboBoxListControl.Items[Index];
if (Item.Checked)
ListText += string.IsNullOrEmpty(ListText) ? Item.Text : String.Format(", {0}", Item.Text);
}
return ListText;
}


这篇关于如何更改checkboxcombobox项目逗号连接分隔符/分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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