C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[72560] ComboBox에 리스트선택하여 StringGrid에 출력하는 것 좀 도와주세요 ㅜㅜ
쿼드콥터헬기 [tatani] 4014 읽음    2015-04-20 23:12
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;

}






+ -

관련 글 리스트
72560 ComboBox에 리스트선택하여 StringGrid에 출력하는 것 좀 도와주세요 ㅜㅜ 쿼드콥터헬기 4014 2015/04/20
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.