如何使用C#以特定格式显示数据 [英] How to display data in specific format using C#

查看:85
本文介绍了如何使用C#以特定格式显示数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我有一个datagridview,我想以特定的格式显示数据,请给我一些解决这个问题的方法。



我是什么尝试过:



我的数据表字符串的格式如p 10-10,p 10-11,p 10-12< br $> b $ b

i想要显示它们就像我的数据网格一样

10-10 10-11 10-12 10-13

pppp



这里p是一个字符串,10-10是我从数据库中恢复的日期

解决方案

< blockquote>对原始字符串(googlec#string split)进行','拆分,这将为您提供一个字符串数组,如p 10-10等等。浏览每个字符串并在''上进行拆分,它将为您提供一个p和10-10数组。因此,将数组的第一项(p)添加到字符串,将第二项添加到不同的字符串。这样你就可以建立两个字符串,一个包含所有p文本,另一个包含数字。


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

解决方案

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.


这篇关于如何使用C#以特定格式显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆