Question about databinding between combobox and dataview

  • Thread starter Thread starter victor
  • Start date Start date
V

victor

hi guys
i get a problem with add databinding between a combobox and a dataview

i have a select statement like
string strCmd = String.Format (
"SELECT Customers.CustomerName, " +
"Call.CallID, " +
"Call.CustomerCode, " +
"Call.ScheduleStarted, " +
"Call.ScheduleEnded, " +
"Call.ActualStarted, " +
"Call.ActualEnded, " +
"Call.CallStatusID, " +
"Call.IsDeleted, " +
"CallStatus.Status " +
"FROM Call INNER JOIN Customers " +
"ON Call.CustomerCode = Customers.CustomerCode " +
"JOIN CallStatus ON Call.CallStatusID = CallStatus.CallStatusID ") ;

then i get a dataset dsCall.

then i set my datagrid's datasource to dsCall.tables["Call"].defaultView;

then i set the valuemember and displaymember for the customer combobox and
call status combobox.


now i add the databinding to my program like

public void AddCallDetailDataBinding()

{
this.cboCustomerName.DataBindings.Add("SelectedValue",this.dvCall,"CustomerCode");

this.dpScheduleStartTime.DataBindings.Add("Value",this.dvCall,"ScheduleStarted");
this.dpScheduleEndTime.DataBindings.Add("Value",this.dvCall,"ScheduleEnded");

this.txtAcutalStartTime.DataBindings.Add("Text",this.dvCall,"ActualStarted");
this.txtAcutalEndTime.DataBindings.Add("Text",this.dvCall,"ActualEnded");

this.cboCallStatus.DataBindings.Add("SelectedValue",this.dvCall,"CallStatusID");

}

Now i when i clicked the datagrid, I could view the call infomation in the
new panel. but when i changed the call info in the panel. it could not
change the info in the datagird.

any suggestion??
cheers
victor
 
What do you do on SelectedIndexChanged in ComboBox? Try moving focus away
fro combo (e.g. call DataGrid.Focus()) and see if it helps
 
I thought after I set the databinding between the combobox and the the
datagrid I dont need to do anything in the SelectedIndexChanged method. so I
didnt implement that method.

And I also try to set the focus to the toplevelcontrol... but still didnt
work

so I really have no idea where i got wrong here.

cheers
victor


Alex Feinman said:
What do you do on SelectedIndexChanged in ComboBox? Try moving focus away
fro combo (e.g. call DataGrid.Focus()) and see if it helps

--
Alex Feinman
---
Visit http://www.opennetcf.org
victor said:
hi guys
i get a problem with add databinding between a combobox and a dataview

i have a select statement like
string strCmd = String.Format (
"SELECT Customers.CustomerName, " +
"Call.CallID, " +
"Call.CustomerCode, " +
"Call.ScheduleStarted, " +
"Call.ScheduleEnded, " +
"Call.ActualStarted, " +
"Call.ActualEnded, " +
"Call.CallStatusID, " +
"Call.IsDeleted, " +
"CallStatus.Status " +
"FROM Call INNER JOIN Customers " +
"ON Call.CustomerCode = Customers.CustomerCode " +
"JOIN CallStatus ON Call.CallStatusID = CallStatus.CallStatusID ") ;

then i get a dataset dsCall.

then i set my datagrid's datasource to dsCall.tables["Call"].defaultView;

then i set the valuemember and displaymember for the customer combobox
and call status combobox.


now i add the databinding to my program like

public void AddCallDetailDataBinding()

{

this.cboCustomerName.DataBindings.Add("SelectedValue",this.dvCall,"CustomerCode");


this.dpScheduleStartTime.DataBindings.Add("Value",this.dvCall,"ScheduleStarted");

this.dpScheduleEndTime.DataBindings.Add("Value",this.dvCall,"ScheduleEnded");


this.txtAcutalStartTime.DataBindings.Add("Text",this.dvCall,"ActualStarted");

this.txtAcutalEndTime.DataBindings.Add("Text",this.dvCall,"ActualEnded");


this.cboCallStatus.DataBindings.Add("SelectedValue",this.dvCall,"CallStatusID");

}

Now i when i clicked the datagrid, I could view the call infomation in
the new panel. but when i changed the call info in the panel. it could
not change the info in the datagird.

any suggestion??
cheers
victor
 
Back
Top