databinding

Implementing sort/page feature when using POCOs with ASP.net Data Controls

I am not a big fan of datasets so I use POCO to return data. I have achieved paging and sorting using custom methods that I create for a POCO type that work on page size and give me a set of the complete POCO collection at a time, I use methods that check for name of the DataItem clicked and sort order to do that sort. Creating such meth...

DataGridView, BindingSource and sorting in vb.net

I am emulating the functionality of an old app in VB.Net. I have a DataGridView on my form which is bound to a BindingSource. I have a button on the toolbar which lanuches a sort dialog. The sort dialog allows sorting by up to 3 columns. So I'm building a string from the results of the dialog and setting the BindingSource.Sort prop...

WPF - Using databinding to bind listbox of items and textboxes of detail

Hi, I am trying set up databinding as described in the title. The problem I having is binding to a generic list. Any examples out there. I can't use BindingListCollectionView on a generic list so have to use CollectionView. The issue I am puzzled about is to add a new item on click of Add button I add a new item to the generic list ...

How can I replace an image in a WPF grid with another control depending on the source data?

I have a grid laid out like so; +---------+---------+ | Image | Details | | is | pane | | here | for data| | | entry | +---------+---------+ | ListView here to | | select data item | | for top two panes | +---------+---------+ This all works well, but I would now like to change the image to another set of cont...

Databinding to a programmaticly created DataTable

Suppose I have a datatable like this: DataTable dt = new DataTable("Woot"); dt.Columns.AddRange(new DataColumn[]{ new DataColumn("ID",typeof(System.Guid)), new DataColumn("Name",typeof(String)) }); When I try to bind a control to it: this.txtName.DataBindings.Add("Text", _d...

Refresh problems with databinding between Listview and ComboBox

Hello, I am wrestling with a binding problem in WPF/Silverlight. I have a Listview witch is filled by a DataContext form an EF linq query. In the same usercontrol are textboxes. When changing their values, the listview gets refresht and the data is changed in de db bij .SaveChanges. The problem is that if I use a combobox the data is sa...

ListBox ItemsSource dynamic filter WPF

Hi I want to make a UI virtualization via the datasource. The idea is to "Filter" what i send to the UI (a listbox in my case). I noticed that the ItemsSource (an observable collection) is read once and that changing the Filter does not trigger refreshing... I don't understand why Thanks Jonathan ...

"Connecting" nonGUI objects to GUI objects.

I have a set of nonGUI objects which have a one to one realtionship with GUI objects. All events are routed through the top level window. Many ( not all ) events occuring on the GUI object result in calling a method on the associated object. Some methods in the NonGui objects which when called change the GUI objects. One example wo...

Bind child Properties to DataGridView

Is there a way to bind the child properties of an object to datagridview? Here's my code: public class Person { private string id; private string name; private Address homeAddr; public string ID { get { return id; } set { id = value; } } public string Name { get { return name; } ...

How do I add an empty first entry do an <asp:DropDownList>?

I have a dropdown, I have a datasource, I have AutoPostBack set to true. I want to add a first entry to the datasource that says something like "--- select country ---" and selecting this entry won't cause postback. This feels like it should be easy to do, yet I can't seem to be able to find a good solution. Thanks. ...

XAML Template Binding Horizontally

I'm wondering how one could use template databinding to accomplish what the following code produces (a grid of checkboxes with some associated text): int tbIndex = 0; for (int i = 1; i < 5; i++) { StackPanel pan = new StackPanel(); pan.Orientation = Orientation.Horizontal; pan.Margin = new Thickness(3); pan.Name = "RowP...

Windows Forms Databinding DisplayMember a Custom Class's Child Property

I'm trying to set the DisplayMember Property of my ListBox in a windows forms project to a property of a nested class inside a Generic List I am binding to. Here's a simple example: public class Security { public int SecurityId { get; set;} public SecurityInfo Info { get; set;} } public class SecurityInfo { public ...

How can I get the Silverlight ComboBox to resize the dropdown after I change ItemsSource?

There are various posts on the web about this issue whereby the ComboBox only changes its dropdown height to fit the items on its very first dropdown. Any changes to the items shown doesn't cause the dropdown to resize. The various workarounds I have found don't seem to work for me, so I was wondering if anyone had found a way to solve t...

Value padded with spaces when displayed in dbaware textfield

Hi, I'm using ADO-components to connect to an access database. In a column defined as text with width 50, dataaware textfields always displays 50 characters even when the actual string value contains less characters. The value gets padded with spaces, and if the textfield is not wide enough, it looks like it is empty. Anyone got any cl...

Databinding in windows forms on an object graph with possible null properties?

If I have an object graph like this: class Company { public Address MainAddress {...} } class Address { public string City { ... } } Company c = new Company(); c.MainAddress = new Address(); c.MainAddress.City = "Stockholm"; and databind to a control using: textBox1.DataBinding.Add( "Text", c, "MainAddress.City" ); Everything is...

WPF User Control

I want to have a User Control that takes a collection of People (property "Data") and displays them in a list box. When I run my app nothing shows in the listbox. Can you please point out what I'm doing wrong? Thanks!!! public class Person { public string Name { get; set; } public int Age { get; set; } public override string...

Why am I losing my databinding when printing to an XpsDocument?

Update! Binding works. The issue is that the XpsDocumentWriter doesn't properly write the first page of the first document of a FixedDocumentSequence. This seems to be an issue encountered by lots of people doing this sort of thing (i.e., five developers worldwide). The solution is slightly odd. I include it as an answer. Okay, i...

Silverlight: How do you bind to control/s in the DataGridTextColumn.HeaderStyle?

I have a datagrid and had the idea of including a comboBox in the header with distinct values for the column it's in - see xaml snippet below of the combo. However I have no idea how to populate / bind to the combo. Apparently silverlight best practice is to avoid "searching" the control tree for "x:name"s and instead setup a data stru...

Programmatically binding List to ListBox

Lets say for instance i have the following extremely simple window: <Window x:Class="CalendarGenerator.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="447"> <Grid> <ListBox Margin="12,40,0,12" Nam...

Databinding in C# and .NET

I am pretty new to C# and .NET and I'm strugling a little with the whole concept of databinding. What I am asking for is a quick rundown of the concept, or even better, point me towards sources on the net (preferred) or in print that can help me get my head around the idea. EDIT: I do my development in vs2008 and we are using winforms ...