Problem with Choose From List - List starts twice
Sebastian Schweer
Hallo Everybody,i programmed a choose from List on all Marketing Documents like the Sales Order to choose an other different Delivery Address.
Due to the fact, that the list ist dynamic and depends on the entry of an other field, i can not initialize the Choose From List by Form Load.
So I Programmed a Button next to a Text Field and this Buttons starts the Choose From List.
But i have one Problem. If i start the Choose From List from the Button, everything works fine. But when i change the Address in the List serveral Times,
and go then to the TextField and Press the Tab - Key, the Choose From List will open two or more times.
How can i avoid that?
Here is the Code i use on the Button:
[CODE]
// Choose From List Button for Ship To Address Event Handler
SwissAddonFramework.UI.EventHandling.ItemEvents.ItemPressedEventHandler delcfl = null;
delcfl = delegate(SwissAddonFramework.UI.EventHandling.ItemEvents.ItemPressed ev)
{
#region Close Form Code
try
{
string sSQL = "SELECT CardCode as 'Code', address as 'Address' FROM crd1 where adresType = 'S' and CardCode = '" + TextEdit.GetFromUID(pVal.Form, "textEditCF").Value.ToString() + "'";
SwissAddonFramework.UI.Dialogs.ChooseFromList cfl =
new SwissAddonFramework.UI.Dialogs.ChooseFromList(
new SwissAddonFramework.UI.Dialogs.ChooseFromList.DefaultSQLQuery(sSQL),
"Address", true, false, TextEdit.GetFromUID(pVal.Form, "txShipToAd"));
// defieniere Event Handler für Choose FROM List
SwissAddonFramework.UI.Dialogs.ChooseFromList.ChooseFromListHandler del = null;
del = delegate (SwissAddonFramework.UI.Dialogs.ChooseFromListEvent evx) { };
cfl.ChooseFromListEvent += new SwissAddonFramework.UI.Dialogs.ChooseFromList.ChooseFromListHandler(del);
// zeige ChooseFromList - Duialog
cfl.ShowInstance(true, "");
}
catch(Exception ex)
{
StatusBar.WriteError("Exception in customize rule: " + ex.Message);
StatusBar.WriteError("Exception in customize rule: " + ex.StackTrace);
}
#endregion
};
[/CODE]
Best Regards,
Sebastian
SeKo
Maybe you should use the AddHandler_Click with a ClickEventHandler instead of the itempressed?Andreas Bimberg
Hi, I think it is a similar problem to mine a few topic below. We would be very interested in a solution too.Paolo Manfrin
Hi,you have to remove the eventhandler from within the method,
otherwise every time you add one more delegate... that's why this is happening.
here a code snippet.
The most important part here is: [color=#000000] pVal[/color][color=#666600].[/color][color=#660066]Form[/color][color=#666600].[/color][color=#660066]RemoveHandler[/color]
[CODE]
if(pVal.Form.Items.ContainsKey("ITEM_UID"))
{
// DO STUFF
}
else
{
SwissAddonFramework.UI.EventHandling.ItemEvents.FormActiveEventHandler delFormActivate = null;
try
{
delFormActivate = delegate (SwissAddonFramework.UI.EventHandling.ItemEvents.FormActivate ev)
{
try
{
pVal.Form.RemoveHandler(ModeComponent.FormModes.ALL, delFormActivate);
// DO STUFF (AGAIN)
}
catch(System.Exception exe)
{
MessageBox.Show("Error happened in FormActivate: " + exe.Message, "OK");
}
};
pVal.Form.AddHandler_Activate(ModeComponent.FormModes.ALL, null, delFormActivate);
}
catch(System.Exception ex)
{
pVal.Form.RemoveHandler(ModeComponent.FormModes.ALL, delFormActivate);
MessageBox.Show("Error happened in FormdataLoad / FormActivate: " + ex.Message, "OK");
}
}
return true;
[/CODE]
0
Please sign in to leave a comment.
Comments
0 comments