Build your own context menu on Form field.

Context menu on field are nothing but the list of features shown when you do right click on field like filter by field,by selection ,setup etc.
Following code illustrates how you can override the standard context menu and build your own .
Best use of this is in-case of display methods where filter by field and selection are not available.
Override the standard context method available on Form fields.

public void context()
{

PopupMenu menu ;
Str filterValue;
int selectedItem;
int filter, removeFilter;
;

//super(); // Comment standard menu

menu = new PopupMenu(element.hWnd());
filter = menu.insertItem("Filter");
removeFilter= menu.insertItem("Remove Filter");

selectedItem = menu.draw();
filterValue = element.design().controlName("Table1_Usn").valueStr();

switch (selectedItem)
{
case filter :
Table1_ds.filter(fieldnum(table1,Usn),filterValue);
break;

case removeFilter :
Table1_ds.removeFilter();
break;

}
}

For illustration i have used my own objects , So please test with your own valid objects.

2 comments:

  1. Hi,How can I add a new ıtem ın the standart context menu ??? this code make new context menu.

    ReplyDelete
  2. Hi Antiope,

    Please try the above code. If it doesn't help please let me know.

    ReplyDelete

Note: Only a member of this blog may post a comment.