简体   繁体   English

在编辑模式下的多行datagridviewcell

[英]multiline datagridviewcell while in edit mode

I am using the following code so that gridview cell support multiline while in edit mode : 我正在使用以下代码,以便在编辑模式下gridview单元支持多行:

private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
   ((DataGridViewTextBoxEditingControl)e.Control).AcceptsReturn = true;
}

when I press SHIFT + ENTER ,gridviewcell provides newline but whole content of cell is not displayed as current line moves up and displays only one line at a time at which your text caret is blinking. 当我按SHIFT + ENTER时 ,gridviewcell提供换行符,但是当当前行向上移动时,单元格的全部内容不会显示,并且您的文本插入符号闪烁时一次仅显示一行。

Is there anyway I can show whole editing cell with multiline while in edit mode itself? 无论如何,在编辑模式本身下,我是否可以用多行显示整个编辑单元格?

try this.... 尝试这个....

The best way is by handling the EditingControlShowing event of the grid and add the following code 最好的方法是通过处理网格的EditingControlShowing事件并添加以下代码

if ((e.Control.GetType() == TextBox))
{
   TextBox txtB = new TextBox();
   txtB = e.Control;
   txtB.Multiline = true;
   txtB.ScrollBars = ScrollBars.Both;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM