如何在数据网格视图中制作多行单元格 [英] how to make multi line cells in data grid view

查看:85
本文介绍了如何在数据网格视图中制作多行单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在Datagridview中创建多行单元格吗?并非所有单元格都选择了我想要制作多行的单元格。以及如何增加datagridiew行的高度

Can i make multi line cell in Datagridview.?? Not all cell only selected cells i want to make multi line. and how can increase the height of datagridiew rows

推荐答案

首先通过设置默认样式使您感兴趣的单元格可以包装...

Firstly make the cells that you are interested in wrappable by setting the default style ...
dataGridView1.Columns[0].DefaultCellStyle.WrapMode = DataGridViewTriState.True;



注意我这里只选择了第一列[0]。如果你想要所有单元格换行,那么使用


Note I've chosen only the first column here [0]. If you wanted all cells to wrap then use

dataGridView1.DefaultCellStyle.WrapMode = DataGridViewTriState.True;



自动增加所有行的高度...


To increase the height of all of the rows automatically ...

dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;

或者如果你想专门针对特定行,那么它就是

or if you want to specifically target specific rows then it's

dataGridView1.AutoResizeRow(RowNumber, DataGridViewAutoSizeRowMode.AllCells);

其中 RowNumber 是一个整数值。我的建议是让控件通过

where RowNumber is some integer value. My advice would be to let the control do the resizing though


这篇关于如何在数据网格视图中制作多行单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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