|
ComboBox에 있는 항목들 중 하나를 선택하여, StringGrid에 그 데이터를 정보를 받아오고 싶은데 잘안됩니다.
일단 csv파일에 있는 데이터를 불러오기는 했는데 어떤 항목을 선택해도 전체리스트를 읽어오네요.. 아직 초보라 모르는 점이 많습니다.ㅠㅠ
* 예로 들어서 combobox에 있는 A라는 항목을 선택을 하면 CSV파일(A,B,C,D 등 항목 및 항목들 별로 세부내용 포함)에 있는 A라는 항목의 세부내용을 StringGrid에 받아오게 끔하고 싶어요
//---------------------------------------------------------------------------
#include <vcl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <mbstring.h>
#pragma hdrstop
#include "Vision_test1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
#pragma warn -aus
char strr[1000];
//-------------------------------------------------------------ReadOptionData
char g_strPathName[100];
char g_strModelName[100];
char OptionData[300][50][100];
char ConditionData[200][100][50];
char TestSpec[500][300][200];
char pszBuffer1[10000];
char textbuf[200];
int TotalColCount=0;
char FullTestActive = 0;
int FullTestStepCount = 0, g_nYangsanStepCount = 0;
int TotalOptionCount=10000, OptionLowCount=33;
//---------------------------------------------------------------------Flag--
int InputSelectFlag1 = 0;
int InputSelectFlag2 = 1;
//---------------------------------------------------------------------------
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//--------------------Option CSV 파일에 있는 모델 읽어오기-------------------
void __fastcall TForm1::FormActivate(TObject *Sender)
{
int i;
ReadOptiondata();
comboxModelSel->Items->Clear();
for(i=0; i<TotalOptionCount; i++) //반복write저장
{
comboxModelSel->Items->Add(OptionData[i+1][1]);
}
}
void __fastcall TForm1::ComboBoxSelect(TObject *Sender)
{
if( InputSelectFlag1 == 0) //마우스 입력
{
SelectModel();
GridDisplay1( g_nYangsanStepCount+2);
}
/*
else if( InputSelectFlag2 == 1)
{
SelectModel();
GridDisplay2( g_nYangsanStepCount+3);
}
*/
else
ShowMessage(" 파일이 없습니다");
}
//------------ComboBox1 Model 선택----------------------------------
void __fastcall TForm1::SelectModel(void)
{
FILE *logfile;
int i, textpoint, k, conbuf, j, err;
char textbuf[200];
// SPEC DATA READ
if( ( logfile = fopen( "D:\\test1\\Option.csv", "rt")) != NULL)
{
i=0;
while(!feof(logfile))
{
fgets( pszBuffer1, 10000, logfile);
for( k=0,textpoint=0; pszBuffer1[ textpoint]!='\n'; )
{
for(j=0; pszBuffer1[textpoint]!=',' && pszBuffer1[textpoint]!='\n' ; j++)
{
textbuf[ j] = pszBuffer1[textpoint++];
}
textbuf[ j] = '\0';
strcpy( ConditionData[ i][k], textbuf);
if( strlen( ConditionData[ i][k] ) == 0 && k == 0)
{
i--;
break;
}
strcpy( TestSpec[ i][k++], textbuf);
if( pszBuffer1[ textpoint]=='\n')
break;
textpoint++;
conbuf = k+1;
}
i++;
}
FullTestStepCount = i;
TotalColCount = k;
fclose(logfile);
}
else
{
err = 1;
ShowMessage( AnsiString( strr )+" 화일이 없습니다");
}
}
//----------------------------------------------------------------------------
void __fastcall TForm1::GridDisplay1(int RowCount)
{
int i,j;
// GRID DISPLAY
for( i=0; i<RowCount; i++)
{
for( j=0; j<TotalColCount; j++)
StringGrid1->Cells[ j][ i] = TestSpec[i][j];
}
}
void __fastcall TForm1::GridDisplay2(int RowCount)
{
int i,j;
// GRID DISPLAY
for( i=0; i<RowCount; i++)
{
for( j=0; j<TotalColCount; j++)
StringGrid1->Cells[ j][ i] = TestSpec[i][j];
}
}
//Option CSV에서 DATA READ
//---------------------------------------------------------------------------
int __fastcall TForm1::ReadOptiondata()
{
FILE *logfile;
int conbuf, textpoint, Realpoint, i, j, k;
char textbuf[200];
if( ( logfile = fopen( "D:\\test1\\Option.csv", "rt")) != NULL)
{
i=0;
while(!feof(logfile))
{
fgets( pszBuffer1, 1000, logfile);
for( k=0,textpoint=0; pszBuffer1[ textpoint]!='\n'; )
{
for(j=0; pszBuffer1[textpoint]!=',' && pszBuffer1[textpoint]!='\n' ; j++)
{
textbuf[ j] = pszBuffer1[textpoint++];
}
textbuf[ j] = '\0';
strcpy( OptionData[ i][k++], textbuf);
if( pszBuffer1[ textpoint]=='\n')
break;
textpoint++;
conbuf = k+1;;
}
i++;
}
}
fclose(logfile);
TotalOptionCount = i;
return 0;
}
|