Tag: datagridview

DataGridView CheckBox事件

我正在制作一个DataGridView其中包含一系列Checkbox,水平和垂直方向相同。 任何相同的标签,复选框都将处于非活动状态,我只希望每个组合的两个“检查”之一有效。 以下屏幕截图显示了我的内容: DataGridView http://sofzh.miximages.com/c%23/2e4m3pz.png 在下半部分检查的任何东西,我都需要在鞋帮上进行UN检查。 因此,如果选中[quux,spam](或基于零坐标的[7,8]),我希望[spam,quux]([8,7])未经检查。 到目前为止我所拥有的是以下内容: dgvSysGrid.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders; dgvSysGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; string[] allsysNames = { “heya”, “there”, “lots”, “of”, “names”, “foo”, “bar”, “quux”, “spam”, “eggs”, “bacon” }; // Add a column for each entry, and a row for each entry, and mark the “diagonals” as readonly for (int i = 0; i […]

带线程的INotifyPropertyChanged

我有一个 BindingList 它绑定到datagridview。 我class上的一个属性需要很长时间来计算,所以我对操作进行了操作。 在计算之后,我引发OnPropertyChanged()事件以通知网格值已准备好。 至少,这就是理论。 但是由于OnPropertyChanged方法是从差异线程调用的,所以我在网格的OnRowPrePaint方法中得到了一些常见的exception。 任何人都可以告诉我如何在主线程中推出OnPropertyChanged事件吗? 我不能使用Form.Invoke,因为类MyClass不知道它在Winforms应用程序中运行。 public class MyClass : INotifyPropertyChanged { public int FastMember {get;set;} private int? slowMember; public SlowMember { get { if (slowMember.HasValue) return slowMember.Value; else { Thread t = new Thread(getSlowMember); t.Start(); return -1; } } } private void getSlowMember() { Thread.Sleep(1000); slowMember = 5; OnPropertyChanged(“SlowMember”); } public […]

数据网格视图中的单元格双击事件

我有两个DataGridView事件。 我有一个问题,当我双击一个单元格时,两个事件,即cell click和cell double click事件被调用。 请告诉我为什么这个问题和最新解决方案。 谢谢

使用dateTimePicker在DataGridView中编辑日期

我的winForms DataGridView中有一个DateTime列; 目前只能通过手动输入日期来编辑字段“2010/09/02”,将DateTimePicker(或等效物)用作编辑器需要什么?

DataGridView中的复选框未触发CellValueChanged事件

我正在使用此代码: // Cell value change event. private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if ((bool)dataGridView1.CurrentCell.Value == true) MessageBox.Show(“true”); if ((bool)dataGridView1.CurrentCell.Value == false) MessageBox.Show(“false”); MessageBox.Show(dataGridView1.CurrentCell.Value.ToString()); } 它适用于所有列,除了一个带有复选框的列( DataGridViewCheckBoxColumn ) 我需要知道复选框列中的值(true或false)。 我需要做些什么呢?

Windows表单应用程序exception

我得到应用程序exception at System.Windows.Forms.CurrencyManager.get_Item(Int32 index) at System.Windows.Forms.CurrencyManager.get_Current() at System.Windows.Forms.DataGridView.DataGridViewDataConnection.OnRowEnter(DataGridViewCellEventArgs e) at System.Windows.Forms.DataGridView.OnRowEnter(DataGridViewCell& dataGridViewCell, Int32 columnIndex, Int32 rowIndex, Boolean canCreateNewRow, Boolean validationFailureOccurred) at System.Windows.Forms.DataGridView.SetCurrentCellAddressCore(Int32 columnIndex, Int32 rowIndex, Boolean setAnchorCellAddress, Boolean validateCurrentCell, Boolean throughMouseClick) at System.Windows.Forms.DataGridView.OnCellMouseDown(HitTestInfo hti, Boolean isShiftDown, Boolean isControlDown) at System.Windows.Forms.DataGridView.OnCellMouseDown(DataGridViewCellMouseEventArgs e) at System.Windows.Forms.DataGridView.OnMouseDown(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at […]

c #datagridview命令行?

我有一个包含多个列的datagridview,其中一列是datetime列。 我想显示最近向下的行。 例如今天昨天昨天前一天等 是否可以使用datagridview执行此操作? gridviews数据源是一个xmldocument ……. 非常感谢。 问候,

如何删除数据网格视图中选中复选框的行?

我正在使用C#.NET 2.0 Visual Studio 2005。 我遇到了奇怪的问题。 有一个简单的窗口forms,只有一个DataGridView,其中column1是复选框(DataGridViewCheckboxColumn) 。 然后,如果选中单元格中的复选框,我想删除选中的行。 声音非常简单,但它不会以某种方式删除所有已检查的行,我无法确定它为什么会以这种方式运行。 例如,我有5行并检查每行中的所有复选框,但它只删除3行。 谁看过这个吗? 这是一个错误还是我做错了什么? namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } //when I click the button, all checked row should be removed private void button1_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dataGridView1.Rows) { if ((bool)row.Cells[0].Value) { […]

C#WinForms DataGridView背景颜色渲染太慢

我正在DataGridView中绘制我的行,如下所示: private void AdjustColors() { foreach (DataGridViewRow row in aufgabenDataGridView.Rows) { AufgabeStatus status = (AufgabeStatus)Enum.Parse(typeof(AufgabeStatus), (string)row.Cells[“StatusColumn”].Value); switch (status) { case (AufgabeStatus.NotStarted): row.DefaultCellStyle.BackColor = Color.LightCyan; break; case (AufgabeStatus.InProgress): row.DefaultCellStyle.BackColor = Color.LemonChiffon; break; case (AufgabeStatus.Completed): row.DefaultCellStyle.BackColor = Color.PaleGreen; break; case (AufgabeStatus.Deferred): row.DefaultCellStyle.BackColor = Color.LightPink; break; default: row.DefaultCellStyle.BackColor = Color.White; break; } } } 然后我在OnLoad方法中调用它: protected override void […]

DataGridView ToolTipText未显示

我在桌面应用程序中有数据绑定DataGridView ,其列设置了ToolTipText属性,但当我将鼠标hover在网格视图(单元格或单元格标题)上时,没有显示工具提示。 网格视图的ShowCellToolTips属性为true ,我已经使用断点validation了在鼠标hover之前它没有以编程方式更改。 我已经尝试创建一个CellToolTipTextNeeded事件处理程序来查看工具提示文本是什么,但从不调用事件处理程序。 有什么我错过了吗? 谢谢,罗布 编辑:我们正在使用框架2.0。