Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Batch Management

Example

  • Last UpdatedJul 26, 2018
  • 13 minute read

The following example illustrates how to use the AVEVA Batch Management ActiveX control. In this example, a single form includes nine lists that represent the basic information available from the control. Basic list boxes are used for each list except for the phase parameters list. Because of the number and sizes of the fields in this list, a list view control was used. The application code shows how the control methods and events are handled. The active batch list is used to focus on a specific batch selected from the list and all other lists update accordingly. There are also several buttons that enable or disable automatically based on the selected items in the lists. The primary goal of this example is to help demonstrate how focusing and event handling should be used. The same concepts shown here can be applied elsewhere in the control. While not shown in these examples, specific application code can be added to provide error messages if the return code for any of the function calls indicates a failure. This example assumes that the Batch ActiveX control has been properly added to the application.

// Beginning of example code with general startup and shutdown logic

private void BatchActiveXControl_Load(object sender, EventArgs e)

{

// Define required local variable

int ReturnCode;

// Set host property and initialize control

OCXBatchCtrl.Host = " BATCHSERVER ";

ReturnCode = OCXBatchCtrl.Init();

}

private void OCXBatchCtrl_SystemShuttingDown(object sender, EventArgs e)

{

// Define required local variable

int ReturnCode;

// Terminate control and end program when system is shutting down

ReturnCode = OCXBatchCtrl.Term();

}

private void PopulateBatch()

{

lstBatches.Items.Clear();

int iNumSchedItems = OCXBatchCtrl.ScheduleSchedGetNumItems();

if (iNumSchedItems > 0)

{

//Populate List Box

lstBatches.Items.Clear();

for (int iIndex = 0; iIndex < iNumSchedItems;iIndex++)

{

OCXBatchCtrl.ScheduleSchedSetSelected((short)iIndex);

string sItem = OCXBatchCtrl.ScheduleSchedGetItem((short)iIndex);

lstBatches.Items.Insert(iIndex, sItem);

}

}

}

private void cmdBatchStart_Click(object sender, EventArgs e)

{

// Define required local variable

int ReturnCode;

// Start the batch when the Batch Start button is pressed

ReturnCode = OCXBatchCtrl.BatchStartBatch("", "", "", "");

}

private void cmdBatchHold_Click(object sender, EventArgs e)

{

// Define required local variable

int ReturnCode;

// Hold the batch when the Batch Hold button is pressed

ReturnCode = OCXBatchCtrl.BatchHoldBatch("", "", "", "");

}

private void cmdBatchRestart_Click(object sender, EventArgs e)

{

// Define required local variable

int ReturnCode;

// ReStart the batch when the Batch ReStart button is pressed

ReturnCode = OCXBatchCtrl.BatchRestartBatch("", "", "", "");

}

private void cmdBatchAbort_Click(object sender, EventArgs e)

{

// Define required local variable

int ReturnCode;

// Abort the batch when the Batch Abort button is pressed

ReturnCode = OCXBatchCtrl.BatchAbortBatch("", "", "", "");

}

private void cmdYes_Click(object sender, EventArgs e)

{

// Define required local variable

int ReturnCode;

//Answer Yes to a question when the Yes button is pressed

ReturnCode = OCXBatchCtrl.QuestAnswerQuest(1, "", "", "", "");

}

private void cmdNo_Click(object sender, EventArgs e)

{

// Define required local variable

int ReturnCode;

//Answer No to a question when the Yes button is pressed

ReturnCode = OCXBatchCtrl.QuestAnswerQuest(0, "", "", "", "");

}

private void cmdForce_Click(object sender, EventArgs e)

{

// Define required local variable

int ReturnCode;

//Answer Yes to a question when the Yes button is pressed

ReturnCode = OCXBatchCtrl.ViewTransitionForceTransition("", "", "", "");

}

private void cmdPhaseStart_Click(object sender, EventArgs e)

{

// Define required local variable

int ReturnCode;

// Start the phase when the Phase Start button is pressed

ReturnCode = OCXBatchCtrl.PhaseStartPhase("", "", "", "");

}

private void cmdPhaseHold_Click(object sender, EventArgs e)

{

// Define required local variable

int ReturnCode;

// Hold the phase when the Phase Hold button is pressed

ReturnCode = OCXBatchCtrl.PhaseHoldPhase("", "", "", "");

}

private void cmdPhaseRestart_Click(object sender, EventArgs e)

{

// Define required local variable

int ReturnCode;

//Restart the phase when the Phase Restart button is pressed

ReturnCode = OCXBatchCtrl.PhaseRestartPhase("", "", "", "");

}

private void cmdPhaseAbort_Click(object sender, EventArgs e)

{

// Define required local variable

int ReturnCode;

//Abort the phase when the Phase Abort button is pressed

ReturnCode = OCXBatchCtrl.PhaseAbortPhase("", "", "", "");

}

private void cmdAcknowledge_Click(object sender, EventArgs e)

{

// Define required local variable

int ReturnCode;

//Acknowledge the phase when the Phase Acknowledge button is pressed

ReturnCode = OCXBatchCtrl.PhaseAckPhase("", "", "", "");

}

private void lstBatches_SelectedIndexChanged(object sender, EventArgs e)

{

// Define required local variables

string CLB;

int ReturnCode;

/*Using batch focus, select the batch that was selected in

the Active Batches list, get the CLB of the selected batch,

and change the focus of the other lists to reflect the

selected batch*/

OCXBatchCtrl.BatchSchedSetSelected((short)lstBatches.SelectedIndex);

CLB = OCXBatchCtrl.BatchSchedGetCLB((short)lstBatches.SelectedIndex);

ReturnCode = OCXBatchCtrl.RecipeSetCLBFocus(CLB);

ReturnCode = OCXBatchCtrl.MessageSetCLBFocus(CLB);

ReturnCode = OCXBatchCtrl.EquipmentSetCLBFocus(CLB);

ReturnCode = OCXBatchCtrl.EditPhaseSetCLBFocus(CLB);

ReturnCode = OCXBatchCtrl.ViewTransitionSetCLBFocus(CLB);

}

private void lstMessages_SelectedIndexChanged(object sender, EventArgs e)

{

// Select the message that was selected in the Batch Messages list

OCXBatchCtrl.MessageMsgSetSelected((short)lstMessages.SelectedIndex);

}

private void lstQuestions_SelectedIndexChanged(object sender, EventArgs e)

{

// Select the message that was selected in the Batch Questions list

OCXBatchCtrl.QuestionQuestSetSelected((short)lstQuestions.SelectedIndex);

}

private void lstTransitions_SelectedIndexChanged(object sender, EventArgs e)

{

// Select the message that was selected in the Batch Transitions list

OCXBatchCtrl.ViewTransitionTagSetSelected((short)lstTransitions.SelectedIndex);

}

private void lstPhases_SelectedIndexChanged(object sender, EventArgs e)

{

// Select the message that was selected in the Batch Transitions list

OCXBatchCtrl.PhasePhaseSetSelected((short)lstPhases.SelectedIndex);

}

private void lvwParameters_SelectedIndexChanged(object sender, EventArgs e)

{

// Select the parameter that was selected in the Phase Parameters list

OCXBatchCtrl.PhaseParamSetSelected((short)lvwParameters.SelectedIndices[0];

}

private void lstEquipment_SelectedIndexChanged(object sender, EventArgs e)

{

// Select the equipment that was selected in the Equipment Allocation list

OCXBatchCtrl.EquipmentEquipSetSelected((short)lstEquipment.SelectedIndex);

}

private void lstEditPhases_SelectedIndexChanged(object sender, EventArgs e)

{

// Select the phase that was selected in the Edit Phase Parameters list

OCXBatchCtrl.EditPhasePhaseSetSelected((short)lstEditPhases.SelectedIndex);

}

// The next group of functions responds to OCXBatch Batch Schedule events

private void OCXBatchCtrl_

(object sender, AxOCXBATCHLib._DOcxBatchEvents_BatchSchedAddEvent e)

{

// Define required local variable

int position;

int Row = e.row;

string Item = e.item;

// Add the new batch item to the Active Batches list at the

//row specified, and if possible, make sure the currently

//selected batch remains selected

position = lstBatches.SelectedIndex;

lstBatches.Items.Insert(Row, Item);

if (position == -1)

lstBatches.SelectedIndex = 0;

else

if (position < Row)

lstBatches.SelectedIndex = position;

else

lstBatches.SelectedIndex = position + 1;

}

private void OCXBatchCtrl_ScheduleSchedAdd(object sender, AxOCXBATCHLib._DOcxBatchEvents_ScheduleSchedAddEvent e)

{

// Define required local variable

int position;

int Row = e.row;

string Item = e.item;

// Add the new batch item to the Active Batches list at the

//e.Row specified, and if possible, make sure the currently

//selected batch remains selected

position = lstBatches.SelectedIndex;

lstBatches.Items.Insert(Row, Item);

if (position == -1)

lstBatches.SelectedIndex = 0;

else

if (position < Row)

lstBatches.SelectedIndex = position;

else

lstBatches.SelectedIndex = position + 1;

}

private void OCXBatchCtrl_BatchSchedBusy(object sender, EventArgs e)

{

// Indicate to the user that the Active Batches list is being updated

lstBatches.Items.Clear();

//lstBatches.Items.Add("Updating...");

Cursor.Current = Cursors.WaitCursor;

}

private void OCXBatchCtrl_BatchSchedChange(object sender, AxOCXBATCHLib._DOcxBatchEvents_BatchSchedChangeEvent e)

{

// Define required local variable

int position;

int Row = e.row;

string Item = e.item;

// Change the batch item in the Active Batches list at the

//Row specified, and make sure the currently selected batch remains selected

position = lstBatches.SelectedIndex;

lstBatches.Items.RemoveAt(Row);

lstBatches.Items.Insert(Row, Item);

lstBatches.SelectedIndex = position;

}

private void OCXBatchCtrl_BatchSchedDelete(object sender, AxOCXBATCHLib._DOcxBatchEvents_BatchSchedDeleteEvent e)

{

// Define required local variable

int position;

int Row = e.row;

// Delete the batch from the Active Batches list at the Row

// specified, and if possible, make sure the currently

// selected batch remains selected

position = lstBatches.SelectedIndex;

lstBatches.SelectedIndex = Row;

lstBatches.Items.RemoveAt(Row);

if (position < Row)

lstBatches.SelectedIndex = position;

else

lstBatches.SelectedIndex = position - 1;

}

private void OCXBatchCtrl_BatchSchedSelect(object sender, AxOCXBATCHLib._DOcxBatchEvents_BatchSchedSelectEvent e)

{

// Define required local variable;

long BatchEditMask = 0;

int Row = e.row;

// Set the batch control buttons accordingly whenever a batch

// is selected in the Active Batches list

if (Row == -1)

{

cmdBatchStart.Enabled = false;

cmdBatchHold.Enabled = false;

cmdBatchRestart.Enabled = false;

cmdBatchAbort.Enabled = false;

}

else

{

BatchEditMask = OCXBatchCtrl.BatchSchedGetEditMask((short)Row);

if((BatchEditMask & 1) == 0)

cmdBatchStart.Enabled = false;

else

cmdBatchStart.Enabled = true;

if((BatchEditMask & 2) == 0)

cmdBatchHold.Enabled = false;

else

cmdBatchHold.Enabled = true;

if ((BatchEditMask & 4) == 0)

cmdBatchRestart.Enabled = false;

else

cmdBatchRestart.Enabled = true;

if ((BatchEditMask & 8) == 0)

cmdBatchAbort.Enabled = false;

else

cmdBatchAbort.Enabled = true;

}

}

private void OCXBatchCtrl_BatchSchedUpdate(object sender, EventArgs e)

{

// Define required local variable;

int i = 0;

// Update the entire Active Batches list lstBatches.Clear();

for (i = 1; i <= OCXBatchCtrl.BatchSchedGetNumItems(); i++)

{

lstBatches.Items.Add(OCXBatchCtrl.BatchSchedGetItem((short)(i - 1)));

}

if (lstBatches.Items.Count > 0)

{

lstBatches.SelectedIndex = 0;

}

else

{

lstBatches.SelectedIndex = -1;

}

Cursor.Current = Cursors.Default;

}

// The next group of functions responds to OCXBatch Edit Phase Parameter events

private void OCXBatchCtrl_EditPhasePhaseAdd(object sender, AxOCXBATCHLib._DOcxBatchEvents_EditPhasePhaseAddEvent e)

{

// Define required local variable

int position = 0;

int Row = e.row;

string Item = e.item;

// Add the new phase item to the Edit Phase Parameters list

//at the row specified, and if possible, make sure the

//currently selected phase remains selected;

position = lstEditPhases.SelectedIndex;

lstEditPhases.Items.Insert(Row, Item);

if (position == -1)

{

lstEditPhases.SelectedIndex = 0;

}

else

{

if (position < Row)

{

lstEditPhases.SelectedIndex = position;

}

else

{

lstEditPhases.SelectedIndex = position + 1;

}

}

}

private void OCXBatchCtrl_EditPhasePhaseDelete(object sender, AxOCXBATCHLib._DOcxBatchEvents_EditPhasePhaseDeleteEvent e)

{

// Define required local variable

int position = 0;

int Row = e.row;

// Delete the phase from the Edit Phase Parameters list at

//the row specified, and if possible, make sure the currently

//selected phase remains selected

position = lstEditPhases.SelectedIndex;

lstEditPhases.Items.RemoveAt(Row);

if (position < Row)

{

lstEditPhases.SelectedIndex = position;

}

else

{

lstEditPhases.SelectedIndex = position - 1;

}

}

private void OCXBatchCtrl_EditPhasePhaseBusy(object sender, EventArgs e)

{

// Indicate to the user that the Edit Phase Parameters listis being updated

Cursor.Current = Cursors.WaitCursor;

}

private void OCXBatchCtrl_EditPhasePhaseUpdate(object sender, EventArgs e)

{

// Define required local variable

int i = 0;

// Update the entire Edit Phase Parameters list

lstEditPhases.Items.Clear();

for (i = 1; i <= OCXBatchCtrl.EditPhasePhaseGetNumItems(); i++)

{

lstEditPhases.Items.Add(OCXBatchCtrl.EditPhasePhaseGetItem((short)

(i - 1)));

}

if (lstEditPhases.SelectedIndex > 0)

{

lstEditPhases.SelectedIndex = 0;

}

else

{

lstEditPhases.SelectedIndex = -1;

}

Cursor.Current = Cursors.Default;

}

//The next group of functions responds to OCXBatch Equipment Allocation events

private void OCXBatchCtrl_EquipmentEquipBusy(object sender, EventArgs e)

{

// Indicate to the user that the Equipment Allocation list is being updated

Cursor.Current = Cursors.WaitCursor;

}

private void OCXBatchCtrl_EquipmentEquipChange(object sender, AxOCXBATCHLib._DOcxBatchEvents_EquipmentEquipChangeEvent e)

{

// Define required local variable

int position = 0;

int Row = e.row;

string Item = e.item;

// Change the equipment item in the Equipment Allocation

//list at the row specified, and make sure the currently

//selected unit or connection remains selected

position = lstEquipment.SelectedIndex;

lstEquipment.Items.RemoveAt(Row);

lstEquipment.Items.Insert(Row, Item);

lstEquipment.SelectedIndex = position;

}

private void OCXBatchCtrl_EquipmentEquipUpdate(object sender, EventArgs e)

{

// Define required local variable

int i = 0;

// Update the entire Equipment Allocation list

lstEquipment.Items.Clear();

for (i = 1; i <= OCXBatchCtrl.EquipmentEquipGetNumItems(); i++)

{

lstEquipment.Items.Add(OCXBatchCtrl.EquipmentEquipGetItem((short)

(i - 1)));

if (lstEquipment.Items.Count > 0)

{

lstEquipment.SelectedIndex = 0;

}

else

{

lstEquipment.SelectedIndex = -1;

}

}

Cursor.Current = Cursors.Default;

}

//The next group of functions responds to OCXBatch Batch Message events

private void OCXBatchCtrl_MessageMsgAdd(object sender, AxOCXBATCHLib._DOcxBatchEvents_MessageMsgAddEvent e)

{

// Define required local variable

int position = 0;

int Row = e.row;

string Item = e.item;

// Add the new message item to the Batch Messages list at

//the row specified, and if possible, make sure the currently

//selected message remains selected

position = lstMessages.SelectedIndex;

lstMessages.Items.Insert(Row, Item);

if (position == -1)

{

lstMessages.SelectedIndex = 0;

}

else

{

if (position < Row)

{

lstMessages.SelectedIndex = position;

}

else

{

lstMessages.SelectedIndex = position + 1;

}

}

}

private void OCXBatchCtrl_MessageMsgBusy(object sender, EventArgs e)

{

// Indicate to the user that the Batch Messages list is being updated;

Cursor.Current = Cursors.WaitCursor;

}

private void OCXBatchCtrl_MessageMsgDelete(object sender, AxOCXBATCHLib._DOcxBatchEvents_MessageMsgDeleteEvent e)

{

// Define required local variable

int position = 0;

int Row = e.row;

// Delete the message from the Batch Messages list at the

//row specified, and if possible, make sure the currently

//selected message remains selected

position = lstMessages.SelectedIndex;

lstMessages.Items.RemoveAt(Row);

if (position < Row)

{

lstMessages.SelectedIndex= position;

}

else

{

lstMessages.SelectedIndex = position - 1;

}

}

private void OCXBatchCtrl_MessageMsgUpdate(object sender, EventArgs e)

{

// Define required local variable

int i = 0;

// Update the entire Batch Messages list

lstMessages.Items.Clear();

for (i = 1; i <= OCXBatchCtrl.MessageMsgGetNumItems(); i++)

{

}

lstMessages.Items.Add(OCXBatchCtrl.MessageMsgGetItem((short)(i - 1)));

if (lstMessages.Items.Count > 0)

{

lstMessages.SelectedIndex = 0;

}

else

{

lstMessages.SelectedIndex = -1;

}

Cursor.Current = Cursors.Default;

}

// The next group of functions responds to OCXBatch Phase Parameter events

private void OCXBatchCtrl_PhaseParamBusy(object sender, EventArgs e)

{

// Indicate to the user that the Batch Messages list is being updated;

Cursor.Current = Cursors.WaitCursor;

}

private void OCXBatchCtrl_PhaseParamChange(object sender, AxOCXBATCHLib._DOcxBatchEvents_PhaseParamChangeEvent e)

{

// Define required local variable

ListViewItem l = null;

int Row = e.row;

string Item = e.item;

// Change the parameter item in the Phase Parameters list at the row specified

l = lvwParameters.SelectedItems[Row];

l.SubItems.Add(Item.Substring(18, 12).Trim());

l.SubItems.Add(Item.Substring(32, 12).Trim());

l.SubItems.Add(Item.Substring(46, 80).Trim());

l.SubItems.Add(Item.Substring(128, 16).Trim());

l.SubItems.Add(Item.Substring(146, 8).Trim());

l.SubItems.Add(Item.Substring(156, 2).Trim());

l.SubItems.Add(Item.Substring(160, 16).Trim());

}

private void OCXBatchCtrl_PhaseParamUpdate(object sender, EventArgs e)

{

// Define required local variables

int i = 0;

ListViewItem l = null;

// Update the entire Phase Parameters list

string Item;

lvwParameters.Items.Clear();

for (i = 1; i <= OCXBatchCtrl.PhaseParamGetNumItems(); i++)

{

Item = (string)OCXBatchCtrl.PhaseParamGetItem((short)i);

l = lvwParameters.Items.Add(Item.Substring(0, 16).Trim());

l.SubItems.Add(Item.Substring(18, 12).Trim());

l.SubItems.Add(Item.Substring(32, 12).Trim());

l.SubItems.Add(Item.Substring(46, 80).Trim());

l.SubItems.Add(Item.Substring(128, 16).Trim());

l.SubItems.Add(Item.Substring(146, 8).Trim());

l.SubItems.Add(Item.Substring(156, 2).Trim());

l.SubItems.Add(Item.Substring(160, 16).Trim());

}

Cursor.Current = Cursors.Default;

}

// The next group of functions responds to OCXBatch Phase events

private void OCXBatchCtrl_PhasePhaseAdd(object sender, AxOCXBATCHLib._DOcxBatchEvents_PhasePhaseAddEvent e)

{

// Define required local variable

int position = 0;

int Row = e.row;

string Item = e.item;

// Add the new phase item to the Phases list at the row

//specified, & if possible, make sure the currently selected phase remains selected;

position = lstPhases.SelectedIndex;

lstPhases.Items.Insert(Row, Item);

if (position == -1)

{

lstPhases.SelectedIndex = 0;

}

else

{

if (position < Row)

{

lstPhases.SelectedIndex = position;

}

else

{

lstPhases.SelectedIndex = position + 1;

}

}

}

private void OCXBatchCtrl_PhasePhaseBusy(object sender, EventArgs e)

{

// Indicate to the user that the Phases list is being updated

Cursor.Current = Cursors.WaitCursor;

}

private void OCXBatchCtrl_PhasePhaseChange(object sender, AxOCXBATCHLib._DOcxBatchEvents_PhasePhaseChangeEvent e)

{

// Define required local variable

int position = 0;

int Row = e.row;

string Item = e.item;

// Change the phase item in the Phases list at the row

//specified, and make sure the currently selected phase remains selected

position = lstPhases.SelectedIndex;

lstPhases.Items.RemoveAt(Row);

lstPhases.Items.Insert(Row, Item);

lstPhases.SelectedIndex = position;

}

private void OCXBatchCtrl_PhasePhaseDelete(object sender, AxOCXBATCHLib._DOcxBatchEvents_PhasePhaseDeleteEvent e)

{

// Define required local variable

int position = 0;

int Row = e.row;

// Delete the phase from the Phases list at the row

//specified, and if possible, make sure the currently

//selected phase remains selected

position = lstPhases.SelectedIndex;

lstPhases.Items.RemoveAt(Row);

if (position < Row)

{

lstPhases.SelectedIndex = position;

}

else

{

lstPhases.SelectedIndex = position - 1;

}

}

private void OCXBatchCtrl_PhasePhaseSelect(object sender, AxOCXBATCHLib._DOcxBatchEvents_PhasePhaseSelectEvent e)

{

// Define required local variable

long PhaseEditMask = 0;

int Row = e.row;

// Set the phase control buttons accordingly

// whenever a phase is selected in the Phases list

PhaseEditMask = OCXBatchCtrl.PhasePhaseGetEditMask((short)Row);

if((PhaseEditMask & 1024) == 0)

cmdPhaseStart.Enabled = false;

else

cmdPhaseStart.Enabled = true;

if ((PhaseEditMask & 128) == 0)

cmdPhaseHold.Enabled = false;

else

cmdPhaseHold.Enabled = true;

if ((PhaseEditMask & 256) == 0)

cmdPhaseRestart.Enabled = false;

else

cmdPhaseRestart.Enabled = true;

if ((PhaseEditMask & 512) == 0)

cmdPhaseAbort.Enabled = false;

else

cmdPhaseAbort.Enabled = true;

if ((PhaseEditMask & 16447) == 0)

cmdPhaseAck.Enabled = false;

else

cmdPhaseAck.Enabled = true;

}

private void OCXBatchCtrl_PhasePhaseUpdate(object sender, EventArgs e)

{

// Define required local variable

int i = 0;

// Update the entire Phases list

lstPhases.Items.Clear();

for (i = 1; i <= OCXBatchCtrl.PhasePhaseGetNumItems(); i++)

{

lstPhases.Items.Add(OCXBatchCtrl.PhasePhaseGetItem((short)(i - 1)));

}

if (lstPhases.Items.Count > 0)

{

lstPhases.SelectedIndex = 0;

}

else

{

lstPhases.SelectedIndex = -1;

}

Cursor.Current = Cursors.Default;

}

// The next group of functions responds to OCXBatch Question events

private void OCXBatchCtrl_QuestionQuestAdd(object sender, AxOCXBATCHLib._DOcxBatchEvents_QuestionQuestAddEvent e)

{

// Define required local variable;

int position = 0;

int Row = e.row;

string Item = e.item;

// Add the new question() item to the Questions list at the

// row specified, & if possible, make sure the currently

// selected question remains selected;

position = lstQuestions.SelectedIndex;

lstQuestions.Items.Insert(Row, Item);

if (position == -1)

{

lstQuestions.SelectedIndex = 0;

}

else

{

if (position < Row)

{

lstQuestions.SelectedIndex = position;

}

else

{

lstQuestions.SelectedIndex = position + 1;

}

}

}

private void OCXBatchCtrl_QuestionQuestBusy(object sender, EventArgs e)

{

// Indicate to the user that the Questions list is being updated

Cursor.Current = Cursors.WaitCursor;

}

private void OCXBatchCtrl_QuestionQuestDelete(object sender, AxOCXBATCHLib._DOcxBatchEvents_QuestionQuestDeleteEvent e)

{

// Define required local variable

int position = 0;

int Row = e.row;

// Delete the question from the Questions list at the row

//specified, and if possible, make sure the currently

//selected question remains selected

position = lstQuestions.SelectedIndex;

lstQuestions.Items.RemoveAt(Row);

if (position < Row)

{

lstQuestions.SelectedIndex = position;

}

else

{

lstQuestions.SelectedIndex = position - 1;

}

}

private void OCXBatchCtrl_QuestionQuestSelect(object sender, AxOCXBATCHLib._DOcxBatchEvents_QuestionQuestSelectEvent e)

{

// Define required local variable

long QuestionType = 0;

int Row = e.row;

// Set the question yes and no buttons accordingly whenever

//a question is selected in the Questions list

if (Row == -1)

{

cmdYes.Enabled = false;

cmdNo.Enabled = false;

}

else

{

QuestionType = OCXBatchCtrl.QuestionQuestGetType((short)Row);

if (QuestionType == 0)

{

cmdYes.Enabled = true;

cmdNo.Enabled = true;

}

else

{

cmdYes.Enabled = true;

cmdNo.Enabled = false;

}

}

}

private void OCXBatchCtrl_QuestionQuestUpdate(object sender, EventArgs e)

{

// Define required local variable

int i = 0;

// Update the entire Questions list

lstQuestions.Items.Clear();

for (i = 1; i <= OCXBatchCtrl.QuestionQuestGetNumItems(); i++)

{

lstQuestions.Items.Add(OCXBatchCtrl.QuestionQuestGetItem((short)

(i - 1)));

}

if (lstQuestions.Items.Count > 0)

{

lstQuestions.SelectedIndex = 0;

}

else

{

lstQuestions.SelectedIndex = -1;

}

Cursor.Current = Cursors.Default;

}

// The next group of functions responds to OCXBatch Transition events

private void OCXBatchCtrl_ViewTransitionTransAdd(object sender, AxOCXBATCHLib._DOcxBatchEvents_ViewTransitionTransAddEvent e)

{

// Define required local variable

int position = 0;

int Row = e.row;

string Item = e.item;

// Add the new transition item to the Transitions list at

//the row specified, and if possible, make sure the currently

//selected transition remains selected

position = lstTransitions.SelectedIndex;

lstTransitions.Items.Insert(Row, Item);

if (position == -1)

{

lstTransitions.SelectedIndex = 0;

}

else

{

if (position < Row)

{

lstTransitions.SelectedIndex = position;

}

else

{

lstTransitions.SelectedIndex = position + 1;

}

}

}

private void OCXBatchCtrl_ViewTransitionTransBusy(object sender, EventArgs e)

{

// Indicate to the user that the Transitions list is being updated

Cursor.Current = Cursors.WaitCursor;

}

private void OCXBatchCtrl_ViewTransitionTransChange(object sender, AxOCXBATCHLib._DOcxBatchEvents_ViewTransitionTransChangeEvent e)

{

// Define required local variable

int position = 0;

int Row = e.row;

string Item = e.item;

// Change the transition item in the Transitions list at the

//row specified, and make sure the currently selected

//transition remains selected

position = lstTransitions.SelectedIndex;

lstTransitions.Items.RemoveAt(Row);

lstTransitions.Items.Insert(Row, Item);

lstTransitions.SelectedIndex = position;

}

private void OCXBatchCtrl_ViewTransitionTransDelete(object sender, AxOCXBATCHLib._DOcxBatchEvents_ViewTransitionTransDeleteEvent e)

{

// Define required local variable

int position = 0;

int Row = e.row;

// Delete the transition from the Transitions list at the

//row specified, and if possible, make sure the currently

//selected transition remains selected

position = lstTransitions.SelectedIndex;

lstTransitions.Items.RemoveAt(Row);

if (position < Row)

{

lstTransitions.SelectedIndex = position;

}

else

{

lstTransitions.SelectedIndex = position - 1;

}

}

private void OCXBatchCtrl_ViewTransitionTransSelect(object sender, AxOCXBATCHLib._DOcxBatchEvents_ViewTransitionTransSelectEvent e)

{

// Define required local variable

int Row = e.row;

// Set the transition force button accordingly whenever a

//transition is selected in the Transitions list

if (Row == -1)

{

cmdForce.Enabled = false;

}

else

{

cmdForce.Enabled = true;

}

}

private void OCXBatchCtrl_ViewTransitionTransUpdate(object sender, EventArgs e)

{

// Define required local variable

int i = 0;

// Update the entire Transitions list

lstTransitions.Items.Clear();

for (i = 1; i <= OCXBatchCtrl.ViewTransitionTransGetNumItems(); i++)

{

lstTransitions.Items.Add(OCXBatchCtrl.ViewTransitionTransGetItem

((short(i - 1)));

}

if (lstTransitions.Items.Count > 0)

{

lstTransitions.SelectedIndex = 0;

}

else

{

lstTransitions.SelectedIndex = -1;

}

Cursor.Current = Cursors.Default;

}

TitleResults for “How to create a CRG?”Also Available in