Jump to content

Datagridview Contextmenusprit Ekleme


korasoglu
 Share

Recommended Posts

int hnd = gridView1.FocusedRowHandle; 
            if (gridView1.IsValidRowHandle(hnd)) // eğer seçili olan satır geçerliyse yani boş bir yere tıklanmamışsa
            {
                if (hnd > -1) // sütun başlıklarına değil de sadece satırlara tıklanmışsa
                {
                    
                    bilgiyukle.id = gridView1.GetRowCellDisplayText(hnd, gridView1.Columns[0]);
                    MessageBox.Show(bilgiyukle.id);
                }
            }

Arkadaşlar bu kodda seçim yoksa deniliyor ve çalışıyor ama ben dataGridView'e aşağıdaki gibi uyguladım boşluğa bile tıklasam contextmenu çıkıyor nasıl yapabilirm.

 private void dataGridView1_MouseClick(object sender, MouseEventArgs e)
        {
            if (dataGridView1CurrentCell.RowIndex > -1)
            {
                if (name == "ISLEM" && e.Button == MouseButtons.Left) {contextMenuStrip1.Show(dataGridView1, e.X, e.Y + 10); }
            }
        }

 

 

  • Like 1
Link to comment
Share on other sites

  • 1 ay sonra...
  • 2 hafta sonra ...

Cevabını arayan olursa;

 if (e.RowIndex != -1 && e.ColumnIndex != -1 && e.ColumnIndex == datagridview.Columns["DURUM"].Index)
            {
                DataGridViewCell clickedCell = (sender as DataGridView).Rows[e.RowIndex].Cells[e.ColumnIndex];
                datagridview.CurrentCell = clickedCell;
                var relativeMousePosition = datagridview.PointToClient(Cursor.Position);
                Menu1.Show(datagridview, relativeMousePosition);
            }

Ama şu bir gerçek yazılımı bana tnc-tr sevdirdi çünkü yardım dükaman çok fazlaydı sorulan sorulara mutlaka cevap veren birileri olurdu misal  pairs(Ali) kintaro(yavuz) ... çok koştular hepsine çok çok teşekkür ederim ama şuan bu bölümle ilgilenen kişi yok galiba ah eski günler.

Edited by korasoglu
  • Like 1
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...