2013年1月31日 星期四

MFC List Control 的使用

Using  MS. VS2010
This artical will show you step by step who to make a 2x2 list view on you MFC application.
The result like following fig:

Step1. From toolbox. select "List control" icon.
 

Step2.  Modify the property of List control
  in "Properties" page, Set "view" = Report
you will see below:
Step3. Add list control variable: Right click on control.
 
Step4. Write you own code for application


// Column Name index
#define COLUMN_NAME      (0)
#define COLUMN_VALUE     (1)

// Row index
#define ITEM_NetxFlag    (0)
#define ITEM_HostFlag    (1)
#define ITEM_HostCOSFlag (2)
#define ITEM_DevCOSFlag  (3)
#define MAX_ROW_INDEX    (4)

// Row Name array
const char ROW_NAME[MAX_ROW_INDEX][16] =
{
  "NetxFlag",
  "HostFlag",
  "HostCOSFlag",
  "DevCOSFlag"
};

// Initial list table.
this->m_infoList.InsertColumn( COLUMN_NAME,  "Name",  0, 80, 50 );
this->m_infoList.InsertColumn( COLUMN_VALUE, "Value", 0, 80, 50 );

for( int i = 0; i < MAX_ROW_INDEX; i++ )
{
  this->m_infoList.InsertItem(  i, ROW_NAME[i]   );     // Set List name.
  this->m_infoList.SetItemText( i, COLUMN_VALUE, "0" );  // Set List value.
}

沒有留言:

張貼留言