MFC MSFlexGrid 사용법 메소
m_Grid.Clear();//Claer
항목체우기 예제
CString strName,strRemarks; m_nCount = 0; // Clear and refresh the grid m_Grid.Clear(); m_Grid.Refresh(); // Get the value for strName from the database here // Get the strRemarks from the database here m_nCols = m_Grid.GetCols(); m_Grid.SetTextArray(0, "Name " ); // First Column m_Grid.SetTextArray(1, "Remarks " ); // Second Column m_nCount++; // Fill First Column m_Grid.SetTextArray( m_nCols * m_nCount + 0,strName ); // Fill Second Column m_Grid.SetTextArray( m_nCols * m_nCount + 1, strRemarks ); // Redraw the grid m_Grid.SetRedraw(TRUE); m_Grid.Refresh();
항목의 글 가져오기
void YourDialog::OnDblClickGrid()
{
// Get the current row and column
int nRow = m_Grid.GetRow();
int nCol = m_Grid.GetCol();
CString strName,strRemarks;
// Get data from the First Column
strName = m_Grid.GetTextMatrix(nRow,nCol+0);
// Get data from the Second Column
strRemarks = m_Grid.GetTextMatrix(nRow,nCol+1);
}
색상 변경
void YourDialog::OnBtnPrevious()
{
m_Grid.SetRedraw(FALSE);
// Get the current selection
int NextRow = m_Grid.GetRowSel();
// If the position is at the last record, return
if(NextRow <= 1)
{
return;
}
else
{
long BackColor[2],FontColor[2];
int Column;
// The BackColor and the FontColor variables
// are manipulated because we want a
// selected effect to be given to the previous
// record. Here, we are merely changing
// the color of the selected
// row to give it that effect.
BackColor[0] = 0x00FFFFFF;
BackColor[1] = 0x00FFFFB0;
FontColor[0] = 0x00400000;
FontColor[1] = 0x000000FF;
for(Column = 1; Column < m_Grid.GetCols(); Column++)
{
m_Grid.SetCol(Column);
m_Grid.SetCellBackColor(BackColor[0]);
m_Grid.SetCellForeColor(FontColor[0]);
}
m_Grid.SetRow(--NextRow);
for(Column = 1; Column < m_Grid.GetCols(); Column++)
{
m_Grid.SetCol(Column);
m_Grid.SetCellBackColor(BackColor[1]);
m_Grid.SetCellForeColor(FontColor[1]);
}
m_Grid.Refresh();
m_Grid.SetRedraw(TRUE);
}
}'개발언어 > c++' 카테고리의 다른 글
| afxv_w32.h(16) : fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include (0) | 2017.01.02 |
|---|---|
| 상속된 템플릿 클래스의 연산자 오버로딩(Operator Overloading) (0) | 2016.11.21 |
| MFC MDI 화면 배경에 이미지 넣기 (0) | 2016.11.16 |
| ATL Error 정보 얻기 (0) | 2016.10.19 |
| CFileDialog 사용법 (0) | 2016.10.19 |