新手:DataGridView中无法输入包含TAB字符的字符串

fangrk 2008-03-08 07:42:20
我用一个DataGridView来显示一个文本文件,DataGridView有两列,第一列是行数,从1开始递增,第二列是文本文件内容。现在发现如果文件中包含了TAB字符的,读取出来正常,但放到DataGridView中就会自动吃掉TAB字符。如何才能原原本本的把文件内容显示出来呢?谢谢!
StreamReader sr = new StreamReader(SelectFileName, Encoding.Default);
int LineCount = 0;
const int MaxLine=50;
while (true){
string FileLine = sr.ReadLine();
if (++LineCount > MaxLine || FileLine == null ) break;
//MessageBox.Show(FileLine);正常
FileView.RowCount = LineCount+1;
FileView.Rows[LineCount-1].Cells[0].Value = LineCount.ToString();
FileView.Rows[LineCount-1].Cells[1].Value = FileLine;//吃掉了TAB字符
FileLine = null;
}
...全文
193 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hrb_it 2008-03-09
  • 打赏
  • 举报
回复
?
fangrk 2008-03-09
  • 打赏
  • 举报
回复
实际上是在datagridview中显示给人的感觉是没有tab字符,但是双击进入编辑状态就会恢复tab显示状态

111,097

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧