Is it possible to use BindingSource.find on multple columns? - vb.net

Is it possible to use BindingSource.find on multple columns?
I have a treeview and a combobox. The combobox provides the ID that is used to build the treeview. When I select a node in the tree view I want to display the details/child information for the ID from the combobox and the tag/ID value from the tree Node.
What is the best way to do this? I was trying to use controls bound to a binding source. I want to change the position of the binding source, but I need to search the binding source for the value from the combo as well as the tree node I just selected?????

I don't know if it is the best way to do what I was trying to accomplish, but BindingSource.Filter method works great for my scenario.

Related

Filtering DataGridView using Comboboxes

Let me preface this by saying I am a beginner as far as .net knowledge.
I am developing a windows form application using tabs in VS2012 in vb. I have bound the datagrid through the designer to a sql server binding source which is populating the data. There are multiple columns in the table and these are split between two tabs with a datagrid on each tab. Both data grids have the same binding source just show different columns.
I created a view within the SQL server to pull in the column names. I think what I want to do and not sure if this is possible but have 2 combo boxes that will be used to filter. One of the would be bound to the view by a dataadapter and then the second to the datagrid binding source.
when the user selects the first combobox(columnname) it would then pull from the datagrid for that column and pull in the valid values to filter. It would then filter the datagridview and refresh it.
Then I am trying to remove the filters through the use of a button.
Can someone please help as I don't even know where to start
You can use Dataview in filtering datasources. You can refer to my answer at this question

Insert/Remove item in listbox bound to database

I want to be able to reorder my listbox which is bound to my sql ce database by clicking up and down arrow buttons. Since my listbox is populated directly from my database using the entity framework, I think I have to delete the object (from the listbox) and reinsert it (in the row above) if I want to move the item up the list.
I have no view model, my listbox is populated directly from my database in my code like this:
listBoxProperties.ItemsSource = entities.Properties.ToList();
Does my question make sense?
Cheers
ormally you would handle the moving of your list item in your view model which would hold the ObservableCollection the control was bound to - and then that would be reflected in your control via the binding.
It is going to get messy trying to accomplish this dirrectly on the control - which is your only way since your binding to a throwaway copy of the EF properties list.
As your UI dev goes on you are only going to run into more issues like this. I strongly recommend getting a view model in place sooner rather that later.

Best way to uniquely name DataGrid Rows % Cells?

In order to support automated testing tools I need to x:Name all controls (so that the tool can "pick it up" and observe its details).
The question is concerning DataGrid where the ItemSoure is bound to a property (in the ViewModel).
What is the best way to ensure all rows and all grid cells are uniquely named?
A better question is: If a DataGrid is x:Named, will automated test tools be able to observe its rows and individual cells, even if the rows/cells are NOT x:Named themselves?
Option 1 (which id like to avoid) is the x:Name each row (on the row loading event, as well as all of its column cells).
Is there perhaps another option where all of these are x:named (uniquely) automatically?
Even better, perhaps all this is not even needed.
In case anybody is interested, i found the answer. Listen for the Row-loaded event. From there recursively traverse down the rows layout/control tree while naming valid controls (while ignoring any layout controls... Grid, StackPanel, Border).

Silverlight ListBox DataTemplate

I have a Silverlight 4 ListBox with a created DataTemplate attached to it that correctly shows the items I want.
I would like to be able to have each Item in the list display differently according to a value in the object that is represented by the DataContext. I was originally looking at altering the DataTemplate on a per item basis, but I think my logic here is flawed.
What is the best way to approach this? Is a Listbox the best way to represent the collection given that I want a potentially different look per item?
I think ur looking for template selector in Silverlight .
Please follow below url http://www.codeproject.com/KB/silverlight/SLTemplateSelector.aspx
-Mahender

Gridview with different template per datasource

I have a gridview that I would like to be able to bind to several sqldatasources, but still use template fields. Each datasource is different and would have different columns so I'm not sure how to go about this. Is it possible to define a set of template fields or overlying template per datasource?
The one way I can think of to do this would be to populate the GridView with rows dynamically from you datasources and then use the OnRowCreated event to switch the fields you want into template fields.
You can either extend the ITemplate interface or you can use a custom ascx control to load into the field like so.
TemplateColumn bc = new TemplateColumn();
bc.HeaderText = "Template Column";
bc.ItemTemplate = Page.LoadTemplate(TEMPLATEFILE);
grid.Columns.Add(bc);
Here are a few good links to help you out if you decide to take this road, really you may get better performance (and less maintainability headaches) from separating them out. Even update panels based on user input would be fine.
Link 1
Link 2
If you want to change your approach and your not sure about which option will suit you best try posting a bit more background about your project and we can go from there.
Happy Coding!
Personally with this it would sound more appropriate to have a separate datagrid control for each one.