Tag: datagridview

根据条件更改datagridview单元格颜色

我已经将数据从数据库加载到datagridview并且有两列目标值和体积,其中体积>目标值,体积单元格应为绿色,体积<目标值,然后体积应为红色。 我尝试过,但我无法做到。 private void dataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) { if (dataGridView1.Rows.Count > 0 && dataGridView1.Columns.Count > 0) { foreach (DataGridViewRow r in dataGridView1.Rows) { if (Volume > target value) { cell.Style.BackColor = Color.AliceBlue; }

我怎么能将DataGridView行拖放到彼此之下?

我有绑定List DataGridView ,我按“ myClass ”中的“ Priority ”属性对其进行排序。 所以我想将“ DataGridViewRow ”拖动到某个位置以更改它的“ Priority ”属性。 我怎么能“拖放”DataGridView行? 以及如何处理?

从DataGridView在运行时动态创建RDLC报告

我有一个表单AdvancedSearchForm与DataGridView控件dgrData和一个按钮Report在C#Winform。 单击按钮Report ,我希望带有ReportView控件的表单显示与DataGridView中具有相同列标题的列相同的列。 使用DataGridView和Button进行表单 单击按钮“报告”时预期的输出: 我的DatagridView ( dgrData )控件与 SQL “Select Id, c_Name from Country” 的ConnectionString server=localhost;User Id=root;password=root;Persist Security Info=True;database=country_state 要在运行时将数据加载到网格,我准备以下DataAdapter : DataAdapter dataAdapter = DataAdapter.Current; // I am passing the SQL statement and the table name to my database which knows the ConnectionString within the LoadData function DataTable dt0 = dataAdapter.LoadData(“select Id, c_Name from […]

如何从DataGridView接收“滚动框”类型滚动事件?

我有一个DataGridView,我正在听它的Scroll事件。 这给了我一个ScrollEventArgs对象,其Type成员应该告诉我已经发生的滚动事件的类型。 在MSDN文档页面上,它说我应该能够通过侦听ThumbPosition,ThumbTrack,First,Last和EndScroll类型的事件来检测滚动框的移动。 但是,当我拖动滚动框时,我只获得LargeDecrement和LargeIncrement类型的事件。 如何访问ThumbPosition,ThumbTrack,First,Last和EndScroll事件?

如何在WinForms项目中将XML用作DataGridView的DataSource?

如何将可编辑的DataGridView链接到WinForms项目中的XML文件?

水平滚动条消失,设置要填充的最后一列大小

我有一个有4列的datagridview。 我想要: 显示每个单元格内的所有文本(我不希望看到任何用“…”截断的文本) 最后一列填充所有剩余空间 水平和垂直滚动条。 使用此代码: dataGridView.ScrollBars = ScrollBars.Both; Grid_NonAnatObj.AutoResizeColumns(); GridCol_Visibility.Width = 30; 我看到每个单元格内的所有文本没有截断,我看到水平和垂直滚动条。 当我尝试添加此代码时 Grid_NonAnatObj.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; 为了满足2.,水平滚动条消失。 我怎么解决这个问题?

如何在messagebox中获取DataGridView单元格值?

如何在C#中的MessageBox中编写DataGridView单元格值?

禁用datagridview中的按钮列

我有一个数据网格视图有4列,前两列是combobox列,第三列是文本框列,第四列是按钮列。在表单加载我必须禁用数据网格的整个按钮列,然后我应该选择前三列和保存后,将这三个列保存在数据库中,特定行中的按钮列应该启用。应该通过单击按钮将第一列保存在数据库中。 请帮助我解决这个问题很多天这里是我使用的代码 private void SATAddTemplate_Load(object sender, EventArgs e) { foreach (DataGridViewRow row in datagrdADDTEMP.Rows) { DataGridViewButtonCell btn = (DataGridViewButtonCell)row.Cells[3]; btn.ReadOnly = true; } } private void btnSaveSettings_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in datagrdADDTEMP.Rows) { DataGridViewButtonCell btn = (DataGridViewButtonCell)row.Cells[3]; btn.ReadOnly = false; } }

如何在c#中打印datagridview的值?

我想打印DGV的整行。 这应该通过提取不拍照的值来完成…(如果你不明白请在下面评论) 有什么方法可以做到这一点吗? 仍面临问题… https://drive.google.com/file/d/0BxqCNfHpYEJlUVg3VW5aZlpHMlk/view?usp=sharing

DataGridView AllowUserToAddRow属性不起作用

我有一个带有Entity Framework的简单项目,我在Form有一个DataGridView ,我将其AllowUserToAddRow属性设置为true但我仍然无法在其中添加新行。 这是我的代码: DBEntities context = new DBEntities(); private void Form1_Load(object sender, EventArgs e) { var q = (from i in context.myTable select i).ToList(); DataGridView.DataSource = q; } private void btnSave_Click(object sender, EventArgs e) { context.SaveChanges(); MessageBox.Show(“saved successfully”); } 如果我使用BindingSource控件,它允许我在DataGridView插入行,但在我调用context.SaveChanges()后,在我的数据库文件中没有插入任何内容。 所以我想也许它的相对于这个问题, DataGridView与true AllowUserToAddRow属性不允许我在DataGridView插入行。