Tag: datagridview

提交更改后,DataGridView行仍然是脏的

在我提交对数据库的更改后, DataGridView.IsCurrentRowDirty仍然为true 。 我想将其设置为false因此当它失去焦点时它不会触发RowValidating 。 我有一个绑定到BindingList的DataGridView 。 我处理CellEndEdit事件并保存对数据库的更改。 保存这些更改后,我希望将DataGridView.IsCurrentRowDirty设置为true ,因为该行中的所有单元格都是最新的; 但是,它设置为false 。 这会给我带来问题,因为当行失去焦点时会触发RowValidating ,我会处理并validation所有三个单元格。所以即使所有单元格都有效且没有一个是脏的,它仍然会validation它们。 那是浪费。 这是我的一个例子: void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { // Ignore cell if it’s not dirty if (dataGridView.isCurrentCellDirty) return; // Validate current cell. } void dataGridView_RowValidating(object sender, DataGridViewCellCancelEventArgs e) { // Ignore Row if it’s not dirty if (!dataGridView.IsCurrentRowDirty) return; // Validate […]

Newtonsoft Json Deserlize作为C#Datagridview

我在使用Newtonsoft Json插件时遇到了一些问题。 我想用Json填充datagridview但不知道如何。 在Newtonsoft Json的文档中,我得到了一个数据表的例子,但如果我尝试这个样本,我只会得到错误。 这是我的Json: [ { “id”: “17”, “name”: “Filename”, “author”: “unknown”, “size”: “3.1MB”, “pfad”: “ftp://path/Filename”, “Filetoken”: “6747rzuzur6urzut766754677” }, { “id”: “20”, “name”: “Filename”, “author”: “unknown”, “size”: “3.1MB”, “pfad”: “ftp://path/Filename”, “Filetoken”: “6747rzuzur6urzut766754677” } ] 我试着用这个例子和这个 也许有人可以帮忙吗?

如何使用用户生成的整数数组填充dataGridView

有了这个: dataGridView.DataSource = theData.Select((x, index) => new { CreatureRoll = x, CreatureLabel = index}).OrderByDescending(x => x.CreatureRoll).ToList(); 它正确地生成数据,但是它会生成数组中的所有行,其中包含无用的额外数据,空数据。 img http://sofzh.miximages.com/c%23/list_Result.jpg?noCache=1379353500 想删除不必要的数据行

将C#datagridview列转换为数组

我正在用c#构建一个程序,并在其中包含了一个datagridview组件。 datagridview具有固定数量的列(2),我想将其保存到两个单独的数组中。 但行数确实发生了变化。 我怎么能这样做?

编辑DataGridview并使用c#将其保存在数据库表中

我使用MYSQL Server作为我的项目后端。我有一个DataGridView,它从数据库中填充数据。 当我在DataGridView单元格中进行更改并单击saveButton时,数据需要在DataGridView和数据库表中进行更改。 在这里我的编码: using MySql.Data.MySqlClient; using System; using System.Data; using System.IO; using System.Windows.Forms; namespace datagridview { public partial class Form1 : Form { DataTable datatab; MySqlDataAdapter mydtadp; MySqlCommandBuilder cmbl; String MyConnection = “SERVER=*****;” + “DATABASE=****;” + “UID=root;” + “PASSWORD=pws”; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { MySqlConnection MyConn = […]

DataGridView图像按钮列

我想在datagridviews列中添加图像按钮。 我使用datagridviewbuttonColumn添加了datagridview,但是我没有将图像设置为this。 我想在datagridviews列中添加带按钮的图像,当单击此按钮时,datagridview行编辑或删除。 请问我该怎么做!

使用编程排序绑定到DataGridView的可排序BindingList

我已经在http://msdn.microsoft.com/en-us/library/aa480736.aspx上实现了SortableSearchableList类,并为它添加了一个Sort方法,如下所示: public void Sort(PropertyDescriptor prop, ListSortDirection direction) { ApplySortCore(prop, direction); } 这个类在通过单击任何列标题对DataGridView进行排序时起作用,但是我需要能够以编程方式调用指定列的Sort方法(在本例中使用sortButton控件)。 我在网上找到的几个代码示例建议获取列的PropertyDescriptor并将其传递给ApplySortCore方法。 我还没有那个工作。 我可以获取DataGridView或SortableSearchableList的PropertyDescriptorCollection属性,但似乎无法获取Find方法来获取指定列/成员的PropertyDescriptor。 这是我的其余代码: namespace SortableBindingListTest { public partial class Form1 : Form { private SortableSearchableList alarms = new SortableSearchableList(); public Form1() { InitializeComponent(); alarms.Add(new Tags(“some text”, “1”)); alarms.Add(new Tags(“more text”, “2”)); alarms.Add(new Tags(“another one”, “3”)); dataGridView1.AutoGenerateColumns = false; dataGridView1.AllowUserToAddRows = true; dataGridView1.EditMode […]

数据网格视图的单个单元格中的C#多色文本

是否可以更改datagridview单元格中存在的子字符串的颜色?

DataGridView没有在c#中更新

有人得到了解释发生了什么? 将代码1更改为代码2可以解决问题 – 尽管理论上应该没有区别。 (理论打击练习就像南瓜击中砖墙)。 代码1: OutputDataGridView.DataSource = myList; 代码2: OutputDataGridView.DataSource = null; OutputDataGridView.DataSource = myList;

DataGridView处理列重新排序事件

我为我的DataGridView对象设置了 AllowUserToOrderColumns = true; 如何检测重新排序的列?