Information générale
Catégorie:
The Mere Mortals .NET Framework
Titre:
Recognizing textbox text change
Versions des environnements
My goal is to select a zip code from a combobox (which contains zip, city and state), and update a separate city textbox and state combobox from the selected combobox entry. The user has the option to overwrite the city and/or state.
The code to place the default city and state into their respective objects is in the Leave of the combobox, and works fine. However, if I do not tab through the city and state objects before pressing the Save button, only the zip code change is saved. When I tab through these two textboxes, the changes to the city and state save ok.
Here's the code from the zip_leave:
if (!(this.zip.Value.ToString() == originalZip))
{
// Locate the City and State Columns & values
int cityIdx = this.zip.DisplayLayout.Bands[0].Columns.IndexOf("City");
int stateIdx = this.zip.DisplayLayout.Bands[0].Columns.IndexOf("State");
string cityName = this.zip.SelectedRow.Cells[cityIdx].Text.ToString();
string stateAbbrev = this.zip.SelectedRow.Cells[stateIdx].Text.ToString();
// Change the city & state only if different from combobox values
if (!(this.txtBl_City.Text.ToString() == cityName))
{
this.txtBl_City.Text = cityName;
}
if (!(this.cboBl_State.Text.ToString() == stateAbbrev))
{
this.cboBl_State.Text = stateAbbreviation;
}
}
The code from the btnSave_Enter:
private void zzButtonSave1_Enter(object sender, System.EventArgs e)
{
// Make sure the PrimaryBizObj is the Parent BizObj
this.PrimaryBizObj = (BLDG_BO)this.GetBizObj("BLDG_BO");
}
This form contains a tab control and on the second tab, child table information is available for updating. Whenever the second tab is activated, the PrimaryBizObj is changed. That's the reason for the above code.
It appears that the dataset is not aware of the changes to the city and state objects. Is there a way to programmatically tell the dataset that changes exist for these two fields? Or, is there a better approach to what I'm trying to do?
TIA -
Patty
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement