problem solved.. 🙂
here is the code..
(just put two TEXTBOX's side by side.. one for your text and the other for line counter..)
int CVICALLBACK AddLine (int panel, int control, int event, void *callbackData,
int eventData1, int eventData2)
{
int textLines,numLines,linesdiff,i;
char TextLineBuf[200];
switch (event)
{
case EVENT_KEYPRESS:
switch (eventData1)
{
case 1280: // < ENTER >
GetCtrlAttribute (panel_handle, SERIAL_TBOX_SEND, ATTR_TOTAL_LINES, &textLines);
GetCtrlAttribute (panel_handle, SERIAL_TBOX_NLINE, ATTR_TOTAL_LINES, &numLines);
numLines=(numLines==0 ? numLines+1 : numLines) ;
linesdiff= numLines -(textLines+1);
if (linesdiff<=0)
{ if (numLines==1)
InsertTextBoxLine (panel, SERIAL_TBOX_NLINE, 0, "N0001");
for (i=(numLines==1 ? 2 : numLines);i<=(textLines+1);i++)
{
sprintf(TextLineBuf, "N%0.4d ", i==1 ? i+1 : i);
InsertTextBoxLine (panel, SERIAL_TBOX_NLINE, i, TextLineBuf);
}
}
else
{
for (i=numLines-1;i>textLines;i--)
{
DeleteTextBoxLine (panel, SERIAL_TBOX_NLINE, i);
}
}
break;
case 512: case 256: // < DELETE >, < BACKSPACE >
GetCtrlAttribute (panel_handle, SERIAL_TBOX_SEND, ATTR_TOTAL_LINES, &textLines);
GetCtrlAttribute (panel_handle, SERIAL_TBOX_NLINE, ATTR_TOTAL_LINES, &numLines);
linesdiff= numLines+2-(textLines+1);
if (linesdiff>0)
{
for (i=numLines-1;i>textLines-1;i--)
{
DeleteTextBoxLine (panel, SERIAL_TBOX_NLINE, i);
}
}
break;
}
break;
}
return 0;
}