Split String into a list and display the list

I need to take a list of emails: dogs@yahoo.com;cats@yahoo.com;horses@yahoo.com;
and split them into a list:
dogs@yahoo.com
cats@yahoo.com
horses@yahoo.com
and then display the list in a way that the values can be selected.
Can anybody help me with some code:
I have this started but it isn’t really working for me in the least:

private void stringtolist()
{
string proofemails = tbProofLastEmail.Text.ToString();
List<string> result = proofemails.Split(new char[] {';'}).ToList();
Console.WriteLine(result);
MessageBox.Show(result.ToString());
}
1 Like

Hi,
Can you export to Excel & complete or does it need to be on Epicor?

If you paste the data to Excel then use Text to Columns, after the text has been converted to columns if you copy it and paste special using the Transpose function it’ll convert to a list rather than columns.

That is great to know. However, in this case I need it all do be done in epicor. The users want it to be as simple and quick as possible.

private void stringtolist()
{
string proofemails = tbProofLastEmail.Text.ToString();
List<string> result = proofemails.Split(new char[] {';'}).ToList();
Console.WriteLine(result);
MessageBox.Show(result.ToString());
}

So, I have this code which returns each value separately. Now I just need to figure out how to display this list in a combo box or checkbox?

1 Like

Try taking your list and binding it to the datasource property of your combobox

c# - Binding a generic List to a ComboBox - Stack Overflow

I don’t know if this will do anything weird in Epicor but similar concept

1 Like

This thread may help:

1 Like

In addition to @TomAlexander 's excellent suggestion of a BAQ, if there is a predefined number of items, one can also use User Codes.

The method I’d suggest depends on what exactly you’re trying to do. Personally, the only time I’ve ever bound a data source in code is when I want to use a ListPickerPanel, mostly because E10 doesn’t let you deploy such a control from the GUI based tools.

1 Like

User Codes offer the ability to separate the displayed string from the value associated with it. So the user could select “Joe Bloggs” and the value would be “jbloggs@gmail.com”. You bind the values to the dropdown via a BAQ that selects user codes with a certain code type.

Beware of using this for any column that appears in an editable EpiGrid, especially where users may paste insert. You’d have to train users to input or paste the values that they never see. My attempts to attach code to the grid to perform the conversion have failed.

1 Like

You can use an array as the data source.
If they need to multi-select, use a grid. If not, you could just use a drop down.
And I agree that if this list is ever going to change, it’s worth the investment to pull it from User Code or BAQ.

string emails = "bob@cats.com;jane@dogs.com;billie@rabbits.com";
string[] emailArray = emails.Split(';');
EpiForm form = new EpiForm(){...};
EpiUltraCombo combo = new EpiUltraCombo();
combo.DataSource = emailArray;

DataGridView grid = new DataGridView(){...};
grid.DataSource = emailArray;

form.Contols.Add(combo);
form.Controls.Add(grid);
form.Show();
1 Like

I like this multi-select option so I think a grid would be best. I can’t do User codes as these emails are all different based upon who an order was sent to via email. There would be hundreds of thousands and not something we keep anywhere else but in this one field.

When I add this code to my customization I am getting a compile error. Did I do something wrong or do I need to replace the periods with something?

1 Like

Unrelated, but this client side customization is going on 8000 lines??? Boy howdy

Most of that isn’t valid C# syntax,
DataGridView(){…}. etc…

You need to actually called the constructors for those objects.

1 Like

Ok, the list is maintained in a UDF.

Sorry, the ellipses can be filled in with property definitions(size, location, …). You also just remove them but you will probably want to mess with size, location, dock style, …
Also, of course, you will need to handle the button clicks and such.

1 Like

Yes it is a completely customized form.

1 Like

@josecgomez
Okay so back to this. I have the results showing in the message box properly. How do I get the results into a grid? It seems like it would be pretty simple?

private void stringtolist()
{
string proofemails = tbProofLastEmail.Text.ToString();
List<string> result = proofemails.Split(new char[] {';'}).ToList();
Console.WriteLine(result);
MessageBox.Show(result.ToString());
}
1 Like

Go through this and learn how to use the DataGridView that should get you what you need.

2 Likes