bindingsource

Bind a TextBox to the Sum of a DataTable Column

谁说胖子不能爱 提交于 2021-02-19 08:15:08
问题 Context I would like to have a footer under my grid to show some stats about the datas. Such as Sum of some columns and average of some other. Half solutions I've found I've found two things intersting to help me do this, binding the databox to a bindingSource, BUT it's only the selected line that is shown into the textBox... myTextBox.DataBindings.add("Text", myGrid.DataSource,"Weight") And getting the Sum of a column in the grid, BUT it doesn't update if I change the grid :S myTextBox.Text

Custom comparer datagridview sort

一个人想着一个人 提交于 2021-02-04 16:35:27
问题 I have a datagridview with a bindingsource as datasource, and the bindingsource has a datatable as a datasource. Some columns are strings but I want them to be sorted in a specific way. The grid sorts them as 1, 10, 10,0 44a, 6c. But I want them to sorted: 1, 6c, 10, 44a, 100 as if i would take the numbers only from the values and sort them accordingly. Is there a way I cand add a custom comparer when certain columns are being sorted? Any other soulutions would be ok if the grid,

Why does DGV cause uncaught exception when removing item from DataSource?

佐手、 提交于 2020-03-03 07:33:34
问题 I have a WinForms application with a DataGridView that has its DataSource property set to a BindingSource (which in turn has its DataSource set to a BindingList). Everything works just fine, until I come to remove items from the BindingSource in response to a user request, the code I use for this is: try { // Get the item currently selected by the DGV var fc = (FooType)FooBindingSource.Current; // Remove the item from the binding source FooBindingSource.Remove(fch); } catch (Exception fault)

Why does DGV cause uncaught exception when removing item from DataSource?

China☆狼群 提交于 2020-03-03 07:33:30
问题 I have a WinForms application with a DataGridView that has its DataSource property set to a BindingSource (which in turn has its DataSource set to a BindingList). Everything works just fine, until I come to remove items from the BindingSource in response to a user request, the code I use for this is: try { // Get the item currently selected by the DGV var fc = (FooType)FooBindingSource.Current; // Remove the item from the binding source FooBindingSource.Remove(fch); } catch (Exception fault)

Why does DGV cause uncaught exception when removing item from DataSource?

感情迁移 提交于 2020-03-03 07:33:09
问题 I have a WinForms application with a DataGridView that has its DataSource property set to a BindingSource (which in turn has its DataSource set to a BindingList). Everything works just fine, until I come to remove items from the BindingSource in response to a user request, the code I use for this is: try { // Get the item currently selected by the DGV var fc = (FooType)FooBindingSource.Current; // Remove the item from the binding source FooBindingSource.Remove(fch); } catch (Exception fault)