DataGridViewCellStyle.WrapMode 属性

定义

获取或设置一个值,该值指示当 DataGridView 单元格中的文本内容太长而不能放在单行中时,是将它换到下一行还是将它截断。Gets or sets a value indicating whether textual content in a DataGridView cell is wrapped to subsequent lines or truncated when it is too long to fit on a single line.

public:
 property System::Windows::Forms::DataGridViewTriState WrapMode { System::Windows::Forms::DataGridViewTriState get(); void set(System::Windows::Forms::DataGridViewTriState value); };
public System.Windows.Forms.DataGridViewTriState WrapMode { get; set; }
member this.WrapMode : System.Windows.Forms.DataGridViewTriState with get, set
Public Property WrapMode As DataGridViewTriState

属性值

DataGridViewTriState 值之一。One of the DataGridViewTriState values. 默认值为 NotSetThe default is NotSet.

异常

属性值不是有效的 DataGridViewTriState 值。The property value is not a valid DataGridViewTriState value.

示例

下面的代码示例演示如何使用此属性。The following code example illustrates the use of this property.

this.dataGridView1.DefaultCellStyle.WrapMode =
    DataGridViewTriState.True;
Me.dataGridView1.DefaultCellStyle.WrapMode = DataGridViewTriState.True

注解

如果对包含文本的单元格 False WrapMode,则单元格将在单个行上显示文本,并将所有嵌入的换行符作为 box 字符显示。If WrapMode is False for a cell that contains text, the cell displays the text on a single line, and displays any embedded newline characters as box characters. 如果对包含文本的单元格 True WrapMode,则单元格将换行符显示为换行符,同时还会包装超出单元宽度的任何行。If WrapMode is True for a cell that contains text, the cell displays newline characters as line breaks, but also wraps any lines that exceed the width of the cell.

适用于

另请参阅