Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
373 views
in Technique[技术] by (71.8m points)

c# - How to set the DataGridViewCell to automatically word wrap?

The code below which I found on MSN did not worked to automatically word-wrap a cell:

dataGridView.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;

dataGridView.Columns[0].DefaultCellStyle.WrapMode = DataGridViewTriState.True;

Any more answer?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You also need to set DataGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells (along with what you have done) for word-wrap to work.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...