bindingsource

BindingSource.Find Multiple Columns

浪子不回头ぞ 提交于 2019-12-11 05:34:49
问题 Is it possible to use the Find method of a BindingSource on multiple columns? For example, say I have a gridview displaying current pets; two comboboxes, cboPetType and cboGender; and a button to create a new record into the Pet table based on the values of these two comboboxes. Now, let's say I only want one of each PetType/Gender combination (Dog - M, Cat - F, etc.). So, if I have a Dog - M pet in my BindingSource and a user selects Dog and M from the comboboxes, I would like to stop the

.Net Filter BindingSource

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 05:19:58
问题 If I filter a BindingSource's column like this: "column1 LIKE '%John%'" , then all rows containing John on that column will return. How to return all rows for which column1 contains [some text]John[some text]Doe ? "column1 LIKE '%John%Doe'" does not work. 回答1: Per the documentation at http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx Wildcard Characters Both the * and % can be used interchangeably for wildcard characters in a LIKE comparison. If the string in a

Binding Source doesn't work on column names with two or more words in DataGridView C#

空扰寡人 提交于 2019-12-11 04:32:32
问题 I am using BindingSource.Filter to filter data on my datagridview. I used the following code: BindingSource bs = new BindingSource(); bs.DataSource = datagridview1.DataSource; bs.Filter = "columnName like '%" + textBox1.Text + "%'"; datagridview1.DataSource = bs; This code works. But when I filter data on a two-word column, the code does not work anymore. I tried putting apostrophe on those words like 'column name' like '%" + tbFilter.Text + "%' , but this does not help. Please help me find

How to make a BindingSource aware of changes in its DataSource?

我是研究僧i 提交于 2019-12-11 03:56:08
问题 I have a: someBindingSource.DataSource = someDataSource; And I also do: someDataSource = foo(); foo() does new for another data source with different data. I don't think it's correct to do the assignment every time the data source changes, i.e: someDataSource = foo(); someBindingSource.DataSource = someDataSource; so is there a way to make someBindingSource aware of change in someDataSource ? 回答1: If the data source implements IBindingList inteface, then the BindingSource will be informed of

.NET BindingSource Filter syntax reference

会有一股神秘感。 提交于 2019-12-10 02:56:24
问题 You can use the Filter property of a BindingSource to do SQL like filtering. For example: bindingSource.Filter= "Activated = 1" Is there something like documentation on the exact syntax of this? I would like to check if a field is not DBNull, so i tried "Field != NULL" but it gives a syntax error. 回答1: The syntax is generally the same as what would you would use in a SQL Where clause, without the "Where", so in this case, it would be bindingSource.Filter = "Field <> NULL"; If you look at msdn

DataGridView / DataTable | rowState doesn't change

懵懂的女人 提交于 2019-12-10 00:50:08
问题 I'm having a problem with binding data to the DataGridView. I have a class MyDataGridView that inherit from DataGridView. My data grid view data source is a BindingSource object that holds a DataTable as the data source. Problem is, when I make changes via (my) DataGridView object - the rowState stays on 'unmodified' instead of modified; even though the values in the DataTable changed (that's what makes my update not work, since it consider the rowState as undefined). Notice that making

How do you get the proper mapping name from a binding source bound to a List<T>, or an anonymous type, to use on a DataGridTableStyle?

喜你入骨 提交于 2019-12-09 14:20:09
问题 I'm trying to create a DataGridTableStyle object so that I can control the column widths of a DataGrid. I've created a BindingSource object bound to a List. Actually it's bound to an anonymous type list created though Linq in the following manner (variable names changed for clarity of what I'm doing): List<myType> myList = new List<myType>(someCapacity); . ...populate the list with query from database... . var query = from i in myList select new { i.FieldA, i.FieldB, i.FieldC };

datatable.GetChanges() shows always first row of DataGridView

为君一笑 提交于 2019-12-08 12:13:39
问题 I have a DataGridView with a Binding-Source bound to a Data-Table loaded from an Oracle-Database. (btw. I don't think that the Database-Connection could cause this) I have also a DataGridViewComboBoxColumn bound to an class of persons (only "has" ID and name), so I can display / allow to edit the name instead of the ID. My problem is now that after the data-binding is completed c# automatically "selects" the first cell of the DGV - see the attached picture. I also have to use this little

Setting AutocompleteMode to Suggest doesn't have an effect

不打扰是莪最后的温柔 提交于 2019-12-08 06:17:30
问题 I have few comboboxes. I initialize their datasources through binding sources (I use EF6). My Combobox Tasks looks like this: So, when I set AutoCompleteMode property to Suggested, the auto complete doesn't work. The weird thing, is that I have two another comboboxes, with (I would say) the exact same setup, and they work...The autocompletion works on them. How to debug this? 回答1: To set up a ComboBox that automatically completes the user's input string, we need to configure 3 different

ADO.NET databinding bug - BindingSource.EndEdit() changes current position

一曲冷凌霜 提交于 2019-12-08 02:04:37
问题 What is the correct order of processing an insert from a data-bound control using BindingSource, DataSet, and TableAdapter? This is causing me eternal confusion. I have a form that is used to add a new row. Before showing the form, I call: bindingSource.AddNew(); bindingSource.MoveLast(); Upon Save, I call: bindingSource.EndEdit(); tableAdapter.Insert([the row given to me as bindingSource.Current]); The problem is that if I don't call EndEdit() , the changes of the TextBox with the current