Before Writing code we have to create string in form Right click on group and now go to string add
Name it diffrent or we can add lable later
create lookup method override
First set the ReplaceOnLookup property of the control to “NO”
Second set the control Autodeclartion property to “Yes”
[Control("String")]
class FormStringControl1
{
/// <summary>
///
/// </summary>
public void lookup()
{
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(Food), this);
Query query = new Query();
QueryBuildDataSource qbds;
sysTableLookup.addLookupField(fieldnum(Food,FoodName ), true);
qbds = query.addDataSource(tablenum(Food));
this.setSelection(strlen(this.text()),strlen(this.text()));
FormStringControl1.text(FormStringControl1.valueStr() + ',');
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
super();
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public boolean modified()
{
boolean ret;
ret = super();
Box::info(strFmt("%1",FormStringControl1.text()));
if(FormStringControl1.text() != '') //Check the combo box has value or not
{
SysQuery::findOrCreateRange( Food_ds.query().dataSourceTable( tableNum( Food )),
fieldNum( Food,FoodName ) ).value( SysQuery::value( FormStringControl1.text() ) );
}
else
{
SysQuery::findOrCreateRange( Food_ds.query().dataSourceTable( tableNum( Food )),
fieldNum( Food,FoodName ) ).value( SysQuery::valueUnlimited() );
}
Food_ds.executeQuery();
return ret;
}
}
[Control("String")]
class FormStringControl2
{
/// <summary>
///
/// </summary>
public void textChange()
{
super();
this.modified();
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public boolean modified()
{
boolean ret;
ret = super();
str nameFilter;
nameFilter = '*'+this.text()+'*';
Food_ds.filter(fieldnum(Food,FoodType ),nameFilter);
return ret;
}
/// <summary>
///
/// </summary>
public void enter()
{
super();
this.setSelection(
strlen(this.text()),
strlen(this.text()));
}
}
Comments
Post a Comment