c# Datagridview de hücre alanına buton ekleme
SanalData’yı Google’da tercih edilen kaynak olarak ekleyinMerhaba arkadaşlar datagridview de bazen hücre alanın ekstra olarak buttonda eklememiz gerekebilir bunun için aşağıdaki kod satırlarını kullanabilirsiniz.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApplication13 { public partial class Form1 : Form { Button button = new Button() { Width = 25, Height = 20 }; int maxHeight = 20; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { button.Visible = false; button.Parent = dataGridView1; } private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { DataGridView grid = sender as DataGridView; if (grid.CurrentCell.RowIndex == e.RowIndex && grid.CurrentCell.ColumnIndex ==e.ColumnIndex) { if (grid.CurrentCell.ColumnIndex.ToString() == "1") { button.Top = e.CellBounds.Top; button.Left = e.CellBounds.Right - button.Width; button.Height = Math.Min(e.CellBounds.Height, maxHeight); button.Text = "..."; button.Invalidate(); button.Visible = true; } } } private void dataGridView1_Enter(object sender, EventArgs e) { button.Parent = (sender as Control); } private void dataGridView1_CellMouseMove(object sender, DataGridViewCellMouseEventArgs e) { } private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { } } } |
Sonuç aşağıdaki gibidir 🙂

Günün zaman çizelgesi
Haber eklenme saatine göre sıralanır.
- Bugün
- Apple’ın metin bildirimli akıllı ev kamerası iddiası
- Apple, iPhone Duo için yeni Shot on iPhone kampanyasını başlattı
- Apple, Brüksel’de teknoloji lobisinin en aktif şirketlerinden
- Apple gündeminde iPhone Duo, AirPods 5 ve mesajla sipariş
- Armadin, yapay zekâ güvenliği için 255,5 milyon dolar topladı
- Lyft, sürücü sınıflandırması davasında 272,5 milyon dolar ödeyecek
- GrayKey, iPhone’un 72 saatlik güvenlik kilidini aşabilir
- Grok’un Maduro operasyonunu Trump’a önerdiği iddia edildi
- GTA 6’nın hava sistemi yerel yağış ve kasırgalar sunacak
- Apple Arcade kataloğuna beş yeni oyun eklendi
- Dün
- Audible, yapay zekâ destekli interaktif hikâyeleri duyurdu
- Kena: Scars of Kosmora’nın çıkışı 2027’ye ertelendi
- Google Gemini Live, küçük yazıları okuyabilecek
- Android Central ekibi işten çıkarıldı, yayınlar sürecek
çok teşekkürler, emeğine sağlık
Rica ederim, yardımcı olabildiysem ne mutlu..