حرکت بین ستون های gridview با زدن اینتر
سلام خدمت دوستان عزیز. من میخوام با زدن اینتر بیت ستونهای دیتاگرید حرکت کنم ولی مشکلم اینجاست که وقتی اینتر رو میزنم اگه درحالت فکوس باشه میپره سطر پایین تر ولی اگه فقط اون ستون رو select کرده باشی به درستی کار میکنه.
من میخوام وقتی داخل یه سلول دارم تایپ میکنم اگه اینتر رو زدم از حالت فکوس بیاد بیرون بره ستون بعد و اونجا فکوس کنه. مثل ورود لیستی کالا تو نرمافزار هلو.
دوستان خواهش میکنم اگه کسی راهشو بلده دریغ نکنه. ممنون میشم.
در ضمن من واسه حرکت بین ستونها از این روش استفاده میکنم که مشکلشو خدمتتون گفتم
private void dataGridViewX1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
int h = dataGridViewX1.CurrentCell.ColumnIndex;
int h1 = dataGridViewX1.CurrentCell.RowIndex;
if (h == dataGridViewX1.Columns.Count - 1)
{
dataGridViewX1.CurrentCell = dataGridViewX1[0, h1 + 1];
}
else
dataGridViewX1.CurrentCell = dataGridViewX1[h + 1, 0];
}
}
نقل قول: حرکت بین ستون های gridview بازدن اینتر
با سلام
بفرمائید
کد کامل فرم :
using System;using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
{
if (msg.WParam.ToInt32() == (int)Keys.Enter)
{
SendKeys.Send("{tab}");
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}
}
کد اصلی:
protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData) {
if (msg.WParam.ToInt32() == (int)Keys.Enter)
{
SendKeys.Send("{tab}");
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
موفق باشید