(others times that info is loaded from the database, so its dynamic)
when the form is loaded for editing, the fields are recovered from the DB and put inside the controls calling the SetValue() method but for the combos thats not enough, because I need to recover the hidden ID (in my example 1 or 0) for each item,..
so If the user dont click in the combo I receipt an error because I need obtain the Id for the selected item to search in the DB but I dont know any automatic option to get that.
(others times that info is loaded from the database, so its dynamic)
when the form is loaded for editing, the fields are recovered from the
DB and put inside the controls calling the SetValue() method but for the
combos thats not enough, because I need to recover the hidden ID (in my
example 1 or 0) for each item,..
so If the user dont click in the combo I receipt an error because I need
obtain the Id for the selected item to search in the DB but I dont know
any automatic option to get that.
Instead of using SetValue (which only sets the string portion of the combo) use SetSelection. That way the combo's value will be the actual item from the list rather than just a string that happens to be the same as one of the items.
···
On 7/30/10 11:04 AM, Mario Lacunza wrote:
Hello,
I have some forms all working fine for add new records, retrieve the
info for editing.. here my problem.
(others times that info is loaded from the database, so its dynamic)
when the form is loaded for editing, the fields are recovered from the
DB and put inside the controls calling the SetValue() method but for the
combos thats not enough, because I need to recover the hidden ID (in my
example 1 or 0) for each item,..
so If the user dont click in the combo I receipt an error because I need
obtain the Id for the selected item to search in the DB but I dont know
any automatic option to get that.
so I need to know how to recover the value 1,0 or 90 when the combo y selected by code...
GetCurrentSelection() return the list position 0,1 or 2...
and with SetSelection() is not a solution because my code dont know whats the list id for the item text "Cien" in my example 90 I need to know then 90==2 in the list position...
Im thinking in create a clone list with the equivalent id
0==1==Alta
1==0==Baja
2==90==Cien
and search on it when the code select de combo item to obtain the DB item id... but I want to discard if there are any wxpython control method to do that.
Thanks!
Mario
···
On 30/07/10 13:56, Robin Dunn wrote:
On 7/30/10 11:04 AM, Mario Lacunza wrote:
Hello,
I have some forms all working fine for add new records, retrieve the
info for editing.. here my problem.
(others times that info is loaded from the database, so its dynamic)
when the form is loaded for editing, the fields are recovered from the
DB and put inside the controls calling the SetValue() method but for the
combos thats not enough, because I need to recover the hidden ID (in my
example 1 or 0) for each item,..
so If the user dont click in the combo I receipt an error because I need
obtain the Id for the selected item to search in the DB but I dont know
any automatic option to get that.
but thats only possible if user trigger the event clicking on the
control, but when that dont happen, I receipt the error; any idea how to
fix that?
Instead of using SetValue (which only sets the string portion of the combo) use SetSelection. That way the combo's value will be the actual item from the list rather than just a string that happens to be the same as one of the items.
so I need to know how to recover the value 1,0 or 90 when the combo y selected by code...
GetCurrentSelection() return the list position 0,1 or 2...
What about:
if self.cboSit.GetCurrentSelection():
self.cboSit.GetClientData(self.cboSit.GetCurrentSelection())
and with SetSelection() is not a solution because my code dont know whats the list id for the item text "Cien" in my example 90 I need to know then 90==2 in the list position...
I am not sure I understand your problem. But maybe SetStringSelection() will work, assuming you know the value (e.g. "Cien") at this point in time.
so I need to know how to recover the value 1,0 or 90 when the combo y selected by code...
GetCurrentSelection() return the list position 0,1 or 2...
What about:
if self.cboSit.GetCurrentSelection():
self.cboSit.GetClientData(self.cboSit.GetCurrentSelection())
and with SetSelection() is not a solution because my code dont know whats the list id for the item text "Cien" in my example 90 I need to know then 90==2 in the list position...
I am not sure I understand your problem. But maybe SetStringSelection() will work, assuming you know the value (e.g. "Cien") at this point in time.