Tag: datagridview

如何在DataGridView控件中实现过滤?

我想开发一个应用程序,它使用DataGridView显示表中的数据。 我想将filter行添加到DataGridView。 这意味着当用户单击filter按钮时,DataGridView应该在DataGridView的开头添加一个空行。 如果用户输入一些数据,具体取决于DataGridView中的字段,则DataGridView应提供与特定单元格输入中的输入相关的快速过滤。 任何人都可以帮我这样做吗?

C#DataGridViewLinkCell显示

是否可以让DataGridViewLinkCell显示类似于search但链接为http://google.com ? 我宁愿DataGridView不会被实际的链接所困扰。

Datagridview列限制

我有一个datagridview表,我需要显示一些数据。在某些情况下,我超过列数限制并得到以下错误: 列’FillWeight值的总和不能超过65535 有没有其他工具可以用来克服这个限制?

Linq到Xml到Datagridview

对,开始疯狂到这里。 我有以下代码: var query = (from c in db.Descendants(“Customer”) select c.Elements()); dgvEditCusts.DataSource = query.ToList(); 在这里,db涉及XDocument.Load调用。 如何将数据导入DataGridView? 我想应该提一下:它会返回一个完全空白的dgv。 并不是说XML太重要了,但这是一个例子: 1 2010-04-13T21:59:46.4642+01:00 Customer Name Address AB1 2XY 0123456789 0123456789 email@address.com

在DataGridView中隐藏行非常慢

我在Winforms应用程序中有一个DataGridView,它有大约1000行(未绑定)和50列。 隐藏一列需要整整2秒钟。 当我想隐藏大约一半的行时,这就成了问题。 private void ShowRows(string match) { this.SuspendLayout(); foreach (DataGridViewRow row in uxMainList.Rows) { if (match == row.Cells[“thisColumn”].Value.ToString())) { row.Visible = false; } else { row.Visible = true; } } this.ResumeLayout(); } 我通过在操作周围添加Console.WriteLine(DateTime.Now)来进行一些测试,而row.Visible = false肯定是慢点。 我错过了一些明显的东西,比如设置IsReallySlow = false ? 或者我是否必须继续启用虚拟模式并编写必要的事件代码?

UI自动化不适用于DataGridView

在尝试了几种解决方案之后,我迫切需要帮助。 我尝试了几种方法,然后才最终复制并仍然坚持使用UIAutomation获取Datagrid的完整内容的解决方案。 让我们谈谈代码,请考虑以下评论: // Get Process ID for desired window handle uint processID = 0; GetWindowThreadProcessId(hwnd, out processID); var desktop = AutomationElement.RootElement; // Find AutomationElement for the App’s window var bw = AutomationElement.RootElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ProcessIdProperty, (int)processID)); // Find the DataGridView in question var datagrid = bw.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.AutomationIdProperty, “dgvControlProperties”)); // Find all rows from the […]

如何检测单元格值改变datagridview c#

对SOF的类似问题似乎没有明确的答案。 我有一个绑定到BindingList对象的DataGridView (它是一个自定义对象列表;也inheritance了INotifyPropertyChanged )。 每个自定义对象都有一个唯一的计时器。 当那些计时器通过一定值(比如10秒)时,我想将单元格的前景颜色更改为红色。 我正在使用CellValueChanged事件,但是这个事件似乎永远不会触发,即使我可以在DataGridView上看到计时器发生变化。 我应该寻找一个不同的事件吗? 下面是我的CellValueChanged处理程序。 private void checkTimerThreshold(object sender, DataGridViewCellEventArgs e) { TimeSpan ts = new TimeSpan(0,0,10); if (e.ColumnIndex < 0 || e.RowIndex 0) { DataGridViewCellStyle cellStyle = new DataGridViewCellStyle(); cellStyle.ForeColor = Color.Red; dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Style = cellStyle; } }

在datagridview中过滤数据c#

我试图过滤掉我想要的数据,并隐藏所有其他数据。 这是我的代码列表, private void searchButton_Click_1(object sender, EventArgs e) { BindingSource bs = new BindingSource(); bs.DataSource = dataGridView1.DataSource; bs.Filter = dataGridView1.Columns[1].HeaderText.ToString() + ” LIKE ‘%” + searchTextBox.Text + “%'”; dataGridView1.DataSource = bs; } 但是当我运行它时,它会提示我错误信息 “’ID’运算符后缺少操作数。” 我也试过这个,同样的错误信息。 private void searchButton_Click_1(object sender, EventArgs e) { BindingSource bs = new BindingSource(); bs.DataSource = dataGridView1.DataSource; // bs.Filter = dataGridView1.Columns[1].HeaderText.ToString() + […]

如何识别右键单击ContextMenuStrip的dataGridView单元格?

用户右键单击DGV中的单元格,然后在ContextMenuStrip中进行选择。 根据他们的CMS选择,我想做点什么(复制,隐藏,过滤)。 我的问题是识别右键单击的单元格。 我试图使用以下方法处理此方案,但无法引用[ColumnIndex]。 private void cmsDataGridView_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { switch (e.ClickedItem.Text) { case “Copy”: break; case “Filter On”: break; case “Hide Column”: DataGridViewBand band = dataGridView1.Columns[e.ColumnIndex]; band.Visible = false; break; } } 我应该用两种不同的方法吗? 一个处理鼠标点击(然后我可以捕获DGV列索引),然后从那里,我调用CMS项目点击事件? 感谢你的帮助,Brian。 适合我的代码。 哦,我必须从设计器中的dataGridView的ContextMenuStrip属性中删除cmsDataGridView方法。 离开那里会引起问题。 // Identify the cell clicked for cmsDataGridView DataGridViewCell clickedCell; private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) […]

DataGridView.Editmode = EditOnEnter。 如何选择要删除的行?

当我使用EditMode = EditOnEnter时,单元格在我选择行时进入editmode。 用户很难选择RowSelector删除行。 你知道任何诡计吗?