[戻]-35597/レス
Re[1]: DataGridViewでAlt+Enterで改行したい
KOZ
2024/04/10(Wed) 05:38:01 編集(投稿者)
■No35596に返信(aksさんの記事)
> DataGridViewで、エクセルのようにセルをAlt+Enterで改行させる事は可能でしょうか?
こんな感じでしょうか?
public class DataGridView_Kai : DataGridView
{
protected override bool ProcessCmdKey(ref Message msg, Keys KeysVal) {
if (IsCurrentCellInEditMode) {
TextBox textBox = EditingControl as TextBox;
if (textBox != null && textBox.Multiline) {
switch (KeysVal) {
case Keys.Enter | Keys.Shift:
return true;
case Keys.Enter | Keys.Alt:
string newLine = Environment.NewLine;
if (textBox.MaxLength == 0 ||
textBox.TextLength - textBox.SelectionLength + newLine.Length <= textBox.MaxLength) {
textBox.SelectedText = newLine;
-->続き
04/09 00:38
[編|消]
35596のレス
35597にレスを書く
<前のレス
Child K-Tai