Click here to Skip to main content
15,925,499 members
Home / Discussions / C#
   

C#

 
Generalerror could not access cdo.message Pin
VIJAYPAPUPAGER30-Jun-04 8:28
VIJAYPAPUPAGER30-Jun-04 8:28 
GeneralRe: error could not access cdo.message Pin
Nick Parker30-Jun-04 8:36
protectorNick Parker30-Jun-04 8:36 
Generalmultiple splitting Pin
blankg30-Jun-04 8:21
blankg30-Jun-04 8:21 
GeneralSerializing and ArrayList Pin
Anonymous30-Jun-04 7:43
Anonymous30-Jun-04 7:43 
GeneralRe: Serializing and ArrayList Pin
Heath Stewart30-Jun-04 8:52
protectorHeath Stewart30-Jun-04 8:52 
GeneralExplorer DragImage Part III Pin
TylerBrinks30-Jun-04 6:36
TylerBrinks30-Jun-04 6:36 
GeneralRe: Explorer DragImage Part III Pin
TylerBrinks30-Jun-04 8:26
TylerBrinks30-Jun-04 8:26 
QuestionControl handles via drag event ? Pin
Guinness4Strength30-Jun-04 6:22
Guinness4Strength30-Jun-04 6:22 
AnswerRe: Control handles via drag event ? Pin
Nick Parker30-Jun-04 6:39
protectorNick Parker30-Jun-04 6:39 
GeneralRe: Control handles via drag event ? Pin
Guinness4Strength30-Jun-04 7:02
Guinness4Strength30-Jun-04 7:02 
GeneralRe: Control handles via drag event ? Pin
Nick Parker30-Jun-04 8:03
protectorNick Parker30-Jun-04 8:03 
AnswerRe: Control handles via drag event ? Pin
StealthyMark4-Jul-04 7:30
StealthyMark4-Jul-04 7:30 
GeneralQuestion on simple binding Pin
Brett Slaski30-Jun-04 4:26
Brett Slaski30-Jun-04 4:26 
GeneralRe: Question on simple binding Pin
Heath Stewart30-Jun-04 8:46
protectorHeath Stewart30-Jun-04 8:46 
GeneralRe: Question on simple binding Pin
Brett Slaski30-Jun-04 9:24
Brett Slaski30-Jun-04 9:24 
GeneralRe: Question on simple binding Pin
Heath Stewart30-Jun-04 18:08
protectorHeath Stewart30-Jun-04 18:08 
GeneralRe: Question on simple binding Pin
Brett Slaski1-Jul-04 2:44
Brett Slaski1-Jul-04 2:44 
GeneralRe: Question on simple binding Pin
Heath Stewart1-Jul-04 4:36
protectorHeath Stewart1-Jul-04 4:36 
Both of those overloads to the same thing. The first actually uses the params to construct a Binding instance and then calls the second overload.

The thing about binding contexts is that they must be bound exactly the same. So, if you bind a ComboBox to a DataTable, then the Binding must also be bound to a DataTable.

I threw together a quick example. The ComboBox.DataSource is bound to a DataTable (in a DataSet). The DisplayMember and ValueMember specify column names (say, "ID" and "Name").

I also defined a property (SelectedValue) that reflects ComboBox.SelectedValue and created a binding in my ctor like so:
this.DataBindings.Add("SelectedValue", dataSet1, "Table1.ID");
The really important part is how you get the binding context. For the back and previous buttons, I threw together this:
private void button1_Click(object sender, System.EventArgs e)
{
  CurrencyManager cm = (CurrencyManager)this.BindingContext
    [this.dataSet1.Table1]; // typed dataset, so table is a prop
  if (cm != null)
    if (cm.Position >= 1) cm.Position--;
}

private void button2_Click(object sender, System.EventArgs e)
{
  CurrencyManager cm = (CurrencyManager)this.BindingContext
    [this.dataSet1.Table1]; // typed dataset, so table is a prop
  if (cm != null)
    if (cm.Position < cm.Count - 1) cm.Position++;
}
Notice that the BindingContext is the table itself - the same as was bound to the ComboBox.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: Question on simple binding Pin
Brett Slaski1-Jul-04 5:54
Brett Slaski1-Jul-04 5:54 
GeneralRe: Question on simple binding Pin
Heath Stewart1-Jul-04 17:48
protectorHeath Stewart1-Jul-04 17:48 
GeneralRe: Question on simple binding Pin
Brett Slaski2-Jul-04 3:08
Brett Slaski2-Jul-04 3:08 
GeneralRe: Question on simple binding Pin
Heath Stewart2-Jul-04 3:40
protectorHeath Stewart2-Jul-04 3:40 
GeneralRe: Question on simple binding Pin
Brett Slaski2-Jul-04 9:25
Brett Slaski2-Jul-04 9:25 
GeneralOOP implemenation question Pin
mealnumberone30-Jun-04 2:27
mealnumberone30-Jun-04 2:27 
GeneralRe: OOP implemenation question Pin
Colin Angus Mackay30-Jun-04 3:15
Colin Angus Mackay30-Jun-04 3:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.