Split comma separated values from Text component
- dmasterplan
- Posts: 143
- Joined: Thu Mar 17, 2022 4:04 am
- Location: Philippines
Split comma separated values from Text component
I have Name-Company,Name-Company value in my Text Component and I want to split it (split comma separated).
and make it
1. Name-Company
2. Name-Company
How/where can I do it? in Databand Before Print event?
and make it
1. Name-Company
2. Name-Company
How/where can I do it? in Databand Before Print event?
Last edited by dmasterplan on Thu Mar 31, 2022 9:18 am, edited 1 time in total.
-
- Posts: 7338
- Joined: Tue Mar 20, 2018 5:34 am
Re: Split comma separated values from Text component
Hello,
What do you need to do with these values after splitting?
Thank you.
What do you need to do with these values after splitting?
Thank you.
- dmasterplan
- Posts: 143
- Joined: Thu Mar 17, 2022 4:04 am
- Location: Philippines
Re: Split comma separated values from Text component
I want to display it again in the same component.Lech Kulikowski wrote: ↑Thu Mar 31, 2022 8:30 am Hello,
What do you need to do with these values after splitting?
Thank you.
With the number before the text. e.g.
1. Name-Company
2. Name-Company
Great Thanks!
-
- Posts: 7338
- Joined: Tue Mar 20, 2018 5:34 am
Re: Split comma separated values from Text component
Hello,
You can use the following code in the BeforePrint event:
or the following expression for split without numeration:
{Variable1.Replace(",","\n")}
Thank you.
You can use the following code in the BeforePrint event:
Code: Select all
var i = 1;
using (System.IO.StringReader sr = new System.IO.StringReader(Variable1.Replace(",","\n")))
{
string line;
while ((line = sr.ReadLine()) != null)
{
Variable2 += i++.ToString() + ". " + line + "\n";
}
}
{Variable1.Replace(",","\n")}
Thank you.
- Attachments
-
- Zrzut ekranu 2022-03-31 151005.png (106.14 KiB) Viewed 1482 times
- dmasterplan
- Posts: 143
- Joined: Thu Mar 17, 2022 4:04 am
- Location: Philippines
Re: Split comma separated values from Text component
This is my code. But I am not getting the correct output:Lech Kulikowski wrote: ↑Thu Mar 31, 2022 1:11 pm Hello,
You can use the following code in the BeforePrint event:or the following expression for split without numeration:Code: Select all
var i = 1; using (System.IO.StringReader sr = new System.IO.StringReader(Variable1.Replace(",","\n"))) { string line; while ((line = sr.ReadLine()) != null) { Variable2 += i++.ToString() + ". " + line + "\n"; } }
{Variable1.Replace(",","\n")}
Thank you.
string Variable1 = dsPackages.Package_In_Charge;
var i = 1;
using (System.IO.StringReader sr = new System.IO.StringReader(Variable1.Replace(",","\n")))
{
string line;
while ((line = sr.ReadLine()) != null)
{
dsPackageInCharge.TextValue += i++.ToString() + ". " + line + "\n";
}
}
I have attached an image of the result.
- Attachments
-
- ss.png (22.85 KiB) Viewed 1460 times
- dmasterplan
- Posts: 143
- Joined: Thu Mar 17, 2022 4:04 am
- Location: Philippines
Re: Split comma separated values from Text component
dsPackageInCharge.TextValue = "";
string Variable1 = dsPackages.Package_In_Charge;
var i = 1;
using (System.IO.StringReader sr = new System.IO.StringReader(Variable1.Replace("-","\n")))
{
string line;
while ((line = sr.ReadLine()) != null)
{
dsPackageInCharge.TextValue += i++.ToString() + ". " + line + "\n";
}
}
We solved it already. It's just not been reset, so we had added dsPackageInCharge.TextValue = "";
in the first line.
Great Thanks
string Variable1 = dsPackages.Package_In_Charge;
var i = 1;
using (System.IO.StringReader sr = new System.IO.StringReader(Variable1.Replace("-","\n")))
{
string line;
while ((line = sr.ReadLine()) != null)
{
dsPackageInCharge.TextValue += i++.ToString() + ". " + line + "\n";
}
}
We solved it already. It's just not been reset, so we had added dsPackageInCharge.TextValue = "";
in the first line.
Great Thanks
-
- Posts: 7338
- Joined: Tue Mar 20, 2018 5:34 am
Re: Split comma separated values from Text component
Hello,
You are welcome.
You are welcome.