Jump to content

Datagridview Sağ Tik


Extended
 Share

Recommended Posts

DataGridView de herhangi bir row a sağ tıklayınca sağ tik menü çıkartıp işlem yaptırabileceğim bir proje örneği verebilir misiniz? Ben sağa tıklamasını algılattım fakat menü çıkartma işlemini çözemedim.

Edited by Extended
Link to comment
Share on other sites

Spoiler

private void dataGridView2_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
        {

            if (e.RowIndex != -1 && e.ColumnIndex != -1)
            {
                if (e.Button == MouseButtons.Right)
                {
                    DataGridViewRow rowsagtik = (sender as DataGridView).Rows[e.RowIndex];
                    if (!rowsagtik.Selected)
                        dataGridView1.CurrentCell = rowsagtik.Cells[e.ColumnIndex];

                    var mousePosition = dataGridView1.PointToClient(Cursor.Position);

                    kayit.Show(dataGridView1, mousePosition);
                }
            }
        }


private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                
                dataGridView1.CurrentCell = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
                dataGridView1.Rows[e.RowIndex].Selected = true;
                dataGridView1.Focus();
                ad = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                soyad = dataGridView1.CurrentRow.Cells[2].Value.ToString();
                
            }
            
        }

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...