نوشته شده توسط
swallow.pa
دوست گرامي اگه تونستي كدها رو بذاريد ما هم ببينيم
البته اگه از نظرتون اشكالي نداشته باشه
در رویداد Cell Enter مربوط به گرید این کد ها :
dataGridView1.Controls.Clear();
Panel1.Visible = false;
if ((dataGridView1.CurrentCell.ColumnIndex == 2) | (dataGridView1.CurrentCell.ColumnIndex == 1) | (dataGridView1.CurrentCell.ColumnIndex == 3))
{
Button MyButton = new System.Windows.Forms.Button();
MyButton.Text = "...";
MyButton.Visible = true;
MyButton.Width = dataGridView1.GetCellDisplayRectangle(e.ColumnInde x, e.RowIndex, true).Height;
MyButton.Height = dataGridView1.GetCellDisplayRectangle(e.ColumnInde x, e.RowIndex, true).Height;
MyButton.Click += new EventHandler(BTN_Click);
dataGridView1.Controls.Add(MyButton);
MyButton.Location = new System.Drawing.Point((dataGridView1.GetCellDisplay Rectangle(e.ColumnIndex, e.RowIndex, true).Right) - ((dataGridView1.GetCellDisplayRectangle(e.ColumnIn dex, e.RowIndex, true).Width)), dataGridView1.GetCellDisplayRectangle(e.ColumnInde x, e.RowIndex, true).Y);
}
تو کد بالا من خواستم با قرار گرفتن در ستونهای 1 و 2 و 3 اون علامت باتن ظاهر بشه که هم با تب کار میکنه هم با ماوس
بعد
public void BTN_Click(object sender, EventArgs e)
{
Button Btn = new Button();
Btn = (Button)sender;
int PanelTop, PanelLeft;
if (dataGridView1.CurrentCell.ColumnIndex==1)
{
DataTable tbl1 = Class1.select("select id,name from tbl1");
dataGridView2.DataSource = tbl1;
dataGridView2.Columns[0].Width = 50;
dataGridView2.Columns[0].HeaderText = "کد ";
dataGridView2.Columns[1].HeaderText = "نام";
PanelTop = Btn.Top +132;
PanelLeft = Btn.Left - 230;
Panel1.Location = new Point(PanelLeft, PanelTop);
Panel1.Visible = true;
dataGridView2.Focus();
}}
دیتاگرید ویو 2 که همون جدول داخل پنل هست که اینجا گفتم مثلا اگر از ستون یک خواستیم لودش کنیم از کدوم جدول و چه مقادیری رو بگیره
و سپس
private void dataGridView2_MouseClick(object sender, MouseEventArgs e)
{
dataGridView1.CurrentCell.Value = dataGridView2.CurrentRow.Cells[0].Value.ToString();
}
البته من خواستم با وارد کردن کد تو هر ستون اون پنل ظاهر بشه و مکاننماش بره رو همون کدی بایسته که ما داریم تایپش میکنیم (یه جور LIke) منتها فعلا نتونستم حلش کنم