How do I get a ComboBox to refresh when the database changes?


Problem

It is important to keep your application in synch with any database updates. Your DX application will not be informed of any updates to the database. Enumerated type widgets use their XmNdataSource widget to access the database and therefore are responsible for keeping their data up to date.

Solution

An Enumerated widget can read any new data from the database by calling XiDBEnumeratedMapEvaluate(Widget widget) and providing the widget id of the Enumerated type widget to be updated.

This example shows a call to XiDBEnumeratedMapEvaluate in response to a callback, or a timer procedure.

void
mytimerproc(client_data, id)
 XtPointer client_data;
 XtIntervalId *id;
{
 
 /* The timer procedure is called only once. In order to have it called 
    periodically it must be registered again */

 XtAppAddTimeOut((XtAppContext)client_data, 60000, mytimerproc, client_data);

 XiDBEnumeratedMapEvaluate(accounts_Account_Number1);
 printf(" Timer called \n");

}

void
myActivateCall(w, client_data, call_data)
 Widget w;
 XtPointer client_data;
 XtPointer call_data;
{
 Widget combo;

 combo = XtNameToWidget(XtParent(XtParent(w)), "*accounts_Account_Number1");

 if (!combo){
   printf("couldn't get combo widget id \n");
 }

 XiDBEnumeratedMapEvaluate(combo);
}



BACK HOME Send Email