Click here to Skip to main content
15,924,317 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello i have a datagridview in which i want to display the data in a specific format please give me some solution to this proble.

What I have tried:

my data-table string is coming in format like " p 10-10, p 10-11, p 10-12 "

i want to display them is my datagridview like
10-10 10-11 10-12 10-13
p p p p

here p is a string and 10-10 is the date which i am retriving from database
Posted
Updated 13-Oct-16 4:43am
Comments
ZurdoDev 13-Oct-16 10:35am    
You'll have to do some parsing of the string. There is no magic code that will do it for you. So, where are you stuck?
#realJSOP 13-Oct-16 14:53pm    
How do you know for sure what year the date is?
Karthik_Mahalingam 18-Oct-16 5:58am    
only one row?

1 solution

Do a split on ',' for the original string (google "c# string split") and that will give you an array of strings like "p 10-10" and so on. Go through each of those strings and do a split on ' ' which will give you an array of "p" and "10-10". So add the first item of the array (the "p") to a string and the second part to a different string. That way you'll build up two strings, one with all the "p" text and one with the numbers.
 
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