databinding

How to bind Xml Attribute to Treeview nodes, while databinding XDocument to WPF Treeview

I have an XML that needs to be databound to a WPF TreeView. Here the XML can have different structure. The TreeView should be databound generic enough to load any permutation of hierarchy. However an XAttribute on the nodes (called Title) should be databound to the TreeViewItem's header text and not the nodename. XML to be bound: <Wiza...

WPF ComboBox binding not working as expected.

I want my WPF ComboBox's ItemsSource property to be bound to MyListObject's MyList property. The problem is that when I update the MyList property in code, the WPF ComboBox is not reflecting the update. I am raising the PropertyChanged event after I perform the update, and I thought WPF was supposed to automatically respond by updating...

How do you rollback changes made to a bound DataGridView?

I have a DataGridView with its datasource set to a generic list of custom objects. As the user changes values (in this case checks/unchecks a check box) the underlying boolean field in the object changes. Should I be creating a "copy" of the List for binding, then updating manually if the user commits, (if so how do you create this copy...

Multiselect listbox binded to database in Delphi 6.

I'm using Delphi 6, and I want a database binded list box with multiselect. I found three types of List boxes: TListBox, TDBListBox and TDBLookupListBox. As far as i can understand, TListbox is not binded to database. TDBListBox and TDBLookupListBox can't be multiselected. Is there a way to get a multiselect listbox binded to databa...

What's the best way to check for errors before leaving a row in a DataGridView

As far as I can tell, the best way to do this is do it in the DataTable.RowChanging event. But what if I want to cancel the action? There is no EventArgs.Cancel option... ...

Add DataSource Property to a Custom WinForms Control

Hi All, I want to add complex databinding to my custom winforms control. So I can do the following: myControl.DisplayMember = "Name"; myControl.ValueMember = "Name"; myControl.DataSource = new List<someObject>(); does anyone know what interfaces etc have to be implemented to achieve this? I've had a look into it and all I can find i...

Access Edit Mode Values of BindingSource Control

I have a BindingSource control (http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.aspx) with a datasource of a (single) Linq object. If I change any of the properties of the underlying Linq-to-Sql object then all the other changes on the bound controls on the form are lost. Does anyone now why and how I work ar...

WPF ComboBox SelectedValue not updating from binding source.

Here's my binding source object: Public Class MyListObject Private _mylist As New ObservableCollection(Of String) Private _selectedName As String Public Sub New(ByVal nameList As List(Of String), ByVal defaultName As String) For Each name In nameList _mylist.Add(name) Next _selectedName = defaultNam...

Setting DataContext with SelectedItem Programatically

How do you programatically set a DataContext that specifies the selected item of a list? More simply, how do you reproduce this type of binding in code? <StackPanel> <ListBox Name="listBox1" /> <TextBox Name="textBox1" DataContext="{Binding ElementName=listBox1, Path=SelectedItem}" /> </StackPanel> ...

Data binding formatting to a DateTime column

I have a textbox with the Text property bound to a dataset column with the DataType set to System.DateTime. The FormatString on the Binding is set to dd-MM-yyyy. When the user enters a date it attempts to convert it to a date but can come up with some strange values for a seemingly invalid date. For example: textBox1.Text = "01-02-200...

DataGridView sort and e.g. BindingList<T> in .NET

Hi Folks I'm using a BindingList<T> in my Windows Forms that contains a list of "IComparable<Contact>" Contact-objects. Now I'd like the user to be able to sort by any column displayed in the grid. There is a way described on MSDN online which shows how to implement a custom collection based on BindingList<T> which allows sorting. But ...

GridView/ObjectDataSource inside runat=server container does not bind

I've got a small web form with 2 radio buttons, call them PickFromList and EnterValue. When PickFromList is checked I want to show a GridView that I've configured to bind to an ObjectDataSource. When EnterValue is checked I want the GridView to disappear. This form is laid out using a table and want to hide/show the appropriate rows b...

Benefits of DataBinding over Manually Querying / Adding to Control

I've been a C# programmer for about 2 years total, and professionally for a little more than 1. I work at a company as a developer on an application that began before the days of .NET 2. My question is this: What is the benefit to use databinding from sql queries directly to a control over querying and manually adding items to the contr...

Databinding DropDown Control in .Net

I am binding the dropdown with db entity. ddlCustomer.DataSource = Customer.GetAll(); ddlCustomer.DataTextField = "CustomerName"; ddlCustomer.DataBind(); I want to add "SELECT" as the first itemlist in dropdown and bind then entity to the dropdown. How can i do this? ...

A better way of forcing data bound WPF ListBox to update?

Hi,, I have WPF ListBox which is bound to a ObservableCollection, when the collection changes, all items update their position. The new position is stored in the collection but the UI does not update. So I added the following: void scenarioItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChange...

Equivalent WPF binding syntax

I need some help with WPF binding syntax: public class ApplicationPresenter { public ObservableCollection<Quotes> PriceList {get;} } public class WebSitePricesView { private IApplicationPresenter presenter { get { return (ApplicationPresenter)DataContext; } } // public ObservableCollection<Quotes> PriceList ...

WPF - Binding IsMouseOver to Visibility

I have a window which overrides a RadioButton's ControlTemplate to show a custom control inside of it. Inside the custom control, I have a button's visibility tied to IsMouseOver, which works correctly in showing the button only when the mouse is hovering over the control. However, when I click on the RadioButton, the Button disappears. ...

Does anyone know a way to "share" a datasource without causing multiple postbacks?

For instance, I have a SqlDataSource that loads a list of items. On my form, I've got 3 dropdown boxes that both should contain that same list of values, and then the user can select a different value for each and save. By hooking up each dropdown list to the same SqlDataSource, the database gets hit three times - one for each object t...

WPF ListBox bind to index of the item

It's easy to bind something to the SelectedIndex of the ListBox, but I want every item in the ListBox be able to bind to it's index in the list. Might sound weird, so here's what I'm trying to do: <DataTemplate x:Key="ScenarioItemTemplate"> <Border Margin="8,2,8,2" Background="#FF3C3B3B" BorderBr...

What is the difference between <%# Bind("") %> and <%# Eval("") %> in ASP.NET?

I have seen bind and eval used interchangeably especially in ASP.NET GridViews. What is the difference? ...