Adding a lookup is done with code similar to this where a lookup was being added to the sales order form, in this case adding a second contact on the delivery tab, most of the code in the event handlers you can ignore its just there for completely showing the example, the trick is to work out which control on the form to add the control to and how to position it, the best option here is to use a decompiler on the form and look at a control that is close to where you want to position your control and work out what its parent is.
A lot of the below was worked out by simply looking at the Jiwa code in the form and replicating it onto the second control.
I doubt you can shorten up the subject box like in your mock up due to the setting the control may already have so you may have to place the two lookups side by side.
- Code: Select all
DeliveryContactNameEditableLookup = new EditableLookup();
salesform.UltraPanel13.ClientArea.Controls.Add(DeliveryContactNameEditableLookup);
//DeliveryContactNameEditableLookup.Location = new Point(lblContactName.Left + lblContactName.Width + 10, 38);
DeliveryContactNameEditableLookup.Location = new Point(lblContactName.Left + lblContactName.Width + 10, salesform.DeliveryAddress1EditableLookup.Top);
DeliveryContactNameEditableLookup.LookupEnabled = true;
DeliveryContactNameEditableLookup.LookupVisible = true;
DeliveryContactNameEditableLookup.Manager = null;
DeliveryContactNameEditableLookup.Margin = new Padding(4);
DeliveryContactNameEditableLookup.MinimumSize = new Size(20, 20);
DeliveryContactNameEditableLookup.Name = "DeliveryContactNameEditableLookup2";
DeliveryContactNameEditableLookup.Size = new Size(402, 21);
DeliveryContactNameEditableLookup.TabIndex = 72;
DeliveryContactNameEditableLookup.Text = null;
DeliveryContactNameEditableLookup.UltraTextEditor.MaxLength = 50;
DeliveryContactNameEditableLookup.TextChanged += new EventHandler(DeliveryContactNameEditableLookup_TextChanged);
DeliveryContactNameEditableLookup.ButtonClicked += new EditableLookup.ButtonClickedEventHandler(DeliveryContactNameEditableLookup_ButtonClicked);
salesform.UltraPanel13.Width = DeliveryContactNameEditableLookup.Left + DeliveryContactNameEditableLookup.Width + 10;
private void DeliveryContactNameEditableLookup_TextChanged(object sender, EventArgs e)
{
if (settingValues)
{
return;
}
string histid = this.salesorder.SalesOrderHistorys[this.salesorder.SelectedHistoryNo].RecID;
SOHistorySecondContact secon = secondcontacts.GetSecondContactForHistID(histid);
secon.SalesOrderHistory = this.salesorder.SalesOrderHistorys[this.salesorder.SelectedHistoryNo];
secon.Contact2Name = DeliveryContactNameEditableLookup.TextBox.Text;
salesform.SetToolBar(true);
}
private void DeliveryContactNameEditableLookup_ButtonClicked(object sender, EventArgs e)
{
try
{
settingValues = true;
clsSearch search = this.manager.Search;
search.Clear();
search.FilterNo = 31019;
search.CurrentOption = 1;
search.Caption = "Debtor With Contacts";
search.UsePinBoard = false;
SearchOption searchOption = this.manager.CollectionItemFactory.CreateCollectionItem<SearchOption>();
SearchOption searchOption1 = searchOption;
string str = string.Concat("SELECT CN_Contact.ContactID, CN_Contact.Title, CN_Contact.FName, CN_Contact.SName, CN_Contact.Mobile", " FROM CN_Contact JOIN CN_Main ");
str = string.Concat(str, " ON (CN_Main.ProspectID = CN_Contact.ProspectID) ");
str = string.Concat(str, " WHERE CN_Main.DebtorID = ", this.manager.Database.FormatChar(this.salesorder.Debtor.DebtorID));
searchOption1.Title = "Debtor With Contacts";
searchOption1.SQLStr = str;
searchOption1.OrderBy = "ORDER BY CN_Contact.FName";
searchOption1.AddColumn("ID", VariantType.String, "", 0, 1, ".", 2, Column.DecimalPlacesTypes.HardCoded, false, ",", -1);
searchOption1.AddColumn("Title", VariantType.String, "", 10, 2, ".", 2, Column.DecimalPlacesTypes.HardCoded, false, ",", -1);
searchOption1.AddColumn("FName", VariantType.String, "", 30, 3, ".", 2, Column.DecimalPlacesTypes.HardCoded, false, ",", -1);
searchOption1.AddColumn("SName", VariantType.String, "", 40, 4, ".", 2, Column.DecimalPlacesTypes.HardCoded, false, ",", -1);
searchOption1.AddColumn("Mobile", VariantType.String, "", 20, 5, ".", 2, Column.DecimalPlacesTypes.HardCoded, false, ",", -1);
this.manager.Search.AddSearchOption(ref searchOption);
searchOption = null;
clsSearch _clsSearch = this.manager.Search;
if (_clsSearch.Show(this.salesform) == DialogResult.OK && _clsSearch.Results.Count != 0)
{
string histid = this.salesorder.SalesOrderHistorys[this.salesorder.SelectedHistoryNo].RecID;
SOHistorySecondContact secon = secondcontacts.GetSecondContactForHistID(histid);
secon.SalesOrderHistory = this.salesorder.SalesOrderHistorys[this.salesorder.SelectedHistoryNo];
secon.Contact2Name = ((JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.Field)_clsSearch.get_Fields(3)).FieldValue.ToString() + " " + ((JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.Field)_clsSearch.get_Fields(4)).FieldValue.ToString();
secon.Mobile2 = ((JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.Field)_clsSearch.get_Fields(5)).FieldValue.ToString();
SetExtraControlValues(secon);
salesform.SetToolBar(true);
}
_clsSearch = null;
}
finally
{
settingValues = false;
}
}