C#:DataGridView 控件中的多行文本 [英] C#: multiline text in DataGridView control

查看:22
本文介绍了C#:DataGridView 控件中的多行文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DataGridView 控件是否可以在单元格中显示多行文本?

Is it possible for the DataGridView control to display multiline text in a cell?

我使用的是 Visual Studio 2005 和 C#.

I am using Visual Studio 2005 and C#.

推荐答案

您应该将列的 DefaultCellStyle.WrapMode 属性设置为 DataGridViewTriState.True.之后,单元格中的文本将正确显示.

You should set DefaultCellStyle.WrapMode property of column to DataGridViewTriState.True. After that text in cells will be displayed correctly.

示例(DataGridView 一列):

dataGridView1.Columns[0].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
dataGridView1.Rows.Add("test" + Environment.NewLine + "test");

(Environment.NewLine = 在 Windows 中)

(Environment.NewLine = in Windows)

这篇关于C#:DataGridView 控件中的多行文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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