Posted 31 January 2020, 2:14 pm EST
Hello,
How do I remove the first 3 characters in a particular column? For example if a column in my grid contains “(1) Testing phase” I only want to display “Testing Phase”.
Thanks,
Victor
Forums Home / ComponentOne / WinForms Edition
Posted by: Victor.m.charles.civ on 31 January 2020, 2:14 pm EST
Posted 31 January 2020, 2:14 pm EST
Hello,
How do I remove the first 3 characters in a particular column? For example if a column in my grid contains “(1) Testing phase” I only want to display “Testing Phase”.
Thanks,
Victor
Posted 3 February 2020, 5:31 am EST
Hi Victor,
Please go through the attached sample which implements how you can remove the first three characters from the particular column.
Regards,
Prabhat Sharma.
TDBDemo1.zip
Posted 3 February 2020, 10:49 am EST
Posted 4 February 2020, 4:45 am EST
Posted 4 February 2020, 3:15 pm EST
Hello,
I’m using the code below to remove the first 3 characters in the 16th column, but doesn’t seem to work because the first couple of rows are blank, it works in other columns with no blank rows. How do I fix this issue?
For i As Integer = 0 To C1TrueDBGrid5.Splits(0).Rows.Count - 1
Dim str As String = C1TrueDBGrid5(i, 16).ToString()
'For removing first 3 characters from column 1
str = str.Remove(0, 3)
C1TrueDBGrid5(i, 16) = str
Next
Thanks,
Victor
Posted 4 February 2020, 5:59 pm EST
Hello,
I’m using the code below to only display the first 16 characters in column 6 but it’s not working, How do I modify the code for it to work?
For i As Integer = 0 To C1TrueDBGrid5.Splits(0).Rows.Count - 1
Dim str As String = C1TrueDBGrid5(i, 16).ToString()
'For displaying first 16 characters use the code snippet given below :
str = str.Remove(6, str.Length - 16)
C1TrueDBGrid5(i, 6) = str
Next
Thanks,
Victor
Posted 5 February 2020, 6:49 am EST
Hi Victor,
>>I’m using the code below to remove the first 3 characters in the 16th column, but doesn’t seem to work because the first couple of rows are blank, it works in other columns with no blank rows. How do I fix this issue?
Use the code snippet given below for the same :
For i As Integer = 0 To C1TrueDBGrid1.Splits(0).Rows.Count - 1
Dim str As String = C1TrueDBGrid1(i, 16).ToString()
'For removing first 3 characters from column 1
If Not String.IsNullOrEmpty(str) Then
str = str.Remove(0, 3)
End If
C1TrueDBGrid1(i, 16) = str
Next
>>I’m using the code below to only display the first 16 characters in column 6 but it’s not working, How do I modify the code for it to work?
Use the code snippet given below for the same :
For i As Integer = 0 To C1TrueDBGrid1.Splits(0).Rows.Count - 1
Dim str As String = C1TrueDBGrid1(i, 6).ToString()
'For displaying the first 16 characters use the code snippet given below :
If str.Length >= 16 Then
str = str.Remove(16, str.Length - 16)
End If
C1TrueDBGrid1(i, 6) = str
Next
I hope it helps.
Regards,
Prabhat Sharma.
Posted 5 February 2020, 10:08 am EST
Hi,
All is working.
Thank You.
Victor