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
[22519] Re: [자답] TreeView 에서 선택한것의 상세내용이 ListView에 동적으로 뜨게 할때...
김성국 [] 1076 읽음    2002-11-08 22:59
김성국 님이 쓰신 글 :
: 탐색기 처럼 옆에 트리에서 선택한 내용이 리스트뷰에서 그대로
: 해당트리내용이 뜨게 하려고 하거든요..
:
: 먼저 node를 생성할때...
:
: TreeView1->Items->Add(Node1,"안씨스트링");
: 이렇게 생성하잔아요...
:
: 근데..listview에서는 탐색기 처럼 생성날짜, 이름, 파일크기, 소유자
: 이런 컬럼등을 나타내야 하는데..
: 노드자체 생성시 안씨 스트링으로 넣어서 노드를 생성시키면
: 생성날짜 파일크기, 소유자등을 어떻게 나타내게 할수 있을까요?
: 원래는 클래스 객체를 만들어서 생성시키고 그것을 넘길려고 햇는데..
: 방법이 보이지 않는군요...검색해도 이 내용은 보이지 않고...
:
: 간단한 예제소스가지고 계신분이나..경험이 잇으신분 부탁드립니다..
:
: 그럼 즐푸~~~
:
:
:
요렇게
=================================================

Adds a new node containing data to a tree view.

=================================================

TTreeNode* __fastcall AddObject(TTreeNode* Node, const System::AnsiString S, void * Ptr);

Description

The node is added as the last sibling of the node specified by the Node parameter.
The S parameter specifies the Text property of the new node.
The Ptr parameter specifies the Data property value of the new node. AddObject returns the node that has been added.

Note:    The memory referenced by Ptr is not freed when the tree nodes object is freed.


The following code defines a record type of TMyRec and a record pointer type of PMyRec.

typedef struct MyRec
{
  AnsiString FName, LName;

} TMyRec;
typedef TMyRec* PMyRec;

Assuming these types are used, the following code adds a node to TreeView1 as the last sibling of a specified node. A TMyRec record is associated with the added item. The FName and LName fields are obtained from edit boxes Edit1 and Edit2. The Index parameter is obtained from edit box Edit3. The item is added only if the Index is a valid value.

void __fastcall TForm1::Button1Click(TObject *Sender)
{
PMyRec  MyRecPtr;
int TreeViewIndex;
TTreeNodes* pItems;

MyRecPtr = new TMyRec;
MyRecPtr->FName = Edit1->Text;
MyRecPtr->LName = Edit2->Text;
TreeViewIndex = StrToInt(Edit3->Text);
pItems = TreeView1->Items;
if (pItems->Count == 0)
   pItems->AddObject(NULL, "Item" + IntToStr(TreeViewIndex), MyRecPtr);
else if ((TreeViewIndex < pItems->Count) && (TreeViewIndex >= 0))

      pItems->AddObject(pItems->Item[TreeViewIndex], "Item" + IntToStr(TreeViewIndex), MyRecPtr);
}

After an item containing a TMyRec record has been added, the following code retrieves the FName and LName values associated with the item and displays the values in a label.

void __fastcall TForm1::Button2Click(TObject *Sender)
{
Label1->Caption = PMyRec(TreeView1->Selected->Data)->FName + " " +
                 PMyRec(TreeView1->Selected->Data)->LName;
}


+ -

관련 글 리스트
22514 TreeView 에서 선택한것의 상세내용이 ListView에 동적으로 뜨게 할때... 김성국 1138 2002/11/08
22519     Re: [자답] TreeView 에서 선택한것의 상세내용이 ListView에 동적으로 뜨게 할때... 김성국 1076 2002/11/08
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.