Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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?
Posted
Updated 14-Apr-16 8:33am
Comments
Karthik_Mahalingam 14-Apr-16 13:31pm    
try other delimiter instead of comma.
Sendano, Nospamo 14-Apr-16 13:47pm    
That is what I am trying to do, change the delimiter the Checkbox is using. Changing the Provider's name format "LastName, FirstName" is not an option.
Karthik_Mahalingam 14-Apr-16 13:55pm    
post your code
Richard Deeming 14-Apr-16 13:57pm    
I'm guessing that your question relates to this article[^]?

If so, you should use the forum at the bottom of the article to ask questions relating to it. The person who wrote the code is the person most likely to be able to help you.

If not, then you need to tell us precisely what CheckBoxComboBox is, and where you got it from.

1 solution

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

///
/// 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;
}
 
Share this answer
 

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