⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 columnselect.cpp

📁 企业员工考勤和工资管理系统
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "ColumnSelect.h"
#include <IniFiles.hpp>

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFormColumnSelect *FormColumnSelect;

//---------------------------------------------------------------------------
__fastcall TFormColumnSelect::TFormColumnSelect(TComponent* Owner)
  : TForm(Owner)
{
  for (int i= 0;i<50;i++)
  {

      pColumn[i] = NULL;

  }
}
//----------------------------------------------
__fastcall TFormColumnSelect::~TFormColumnSelect()
{
 for (int i= 0;i<50;i++)
  {
    if (pColumn[i])
    {
      delete pColumn[i];
      pColumn[i] = NULL;
    }
  }
}
//-----------------------------------------------------

//-----------------------------------------------------
void __fastcall TFormColumnSelect::SetColumn()
{
  int nLeft,nTop;
  nLeft = 0;
  nTop = 0;
  for (int i = 0;i<pGrid->Columns->Count;i++)
  {
    pColumn[i] = new TCheckBox(this);
    pColumn[i]->Parent = Panel1;
    pColumn[i]->Caption = pGrid->Columns->Items[i]->Title->Caption ;
    pColumn[i]->Width = strlen(pGrid->Columns->Items[i]->Title->Caption.c_str()) * 6 + 30;
    pColumn[i]->Checked = pGrid->Columns->Items[i]->Visible;
    //if ((Panel1->Width - nLeft) < pColumn[i]->Width)
    if ((Panel1->Width - nLeft) < 84)
    {
      nTop = nTop + pColumn[i]->Height + 10;
      if ((Panel1->Height - nTop) < pColumn[i]->Height)
      {
        Panel1->Height = Panel1->Height + pColumn[i]->Height;
        for(int j = 0;j < ControlCount;j++)
        {
          if (Controls[j]->Top <= Panel1->Top) continue;
          Controls[j]->Top += pColumn[i]->Height;
        }
        Height += pColumn[i]->Height +2;
      }
      nLeft = 0;
    }
    pColumn[i]->Top = nTop+ 6;
    pColumn[i]->Left = nLeft + 10;

    //nLeft = nLeft + pColumn[i]->Width;
    nLeft = nLeft + 100;

  }
}
//-------------------------------------------------------
void __fastcall TFormColumnSelect::BitBtn1Click(TObject *Sender)
{
  Close();
}
//---------------------------------------------------------------------------




void __fastcall TFormColumnSelect::BitBtnPreviewClick(TObject *Sender)
{
  TIniFile* pIni = new TIniFile(ExtractFilePath(Application->ExeName) + "reckq.ini");
  for (int i = 0;i < pGrid->Columns->Count ; i++)
  {
    pGrid->Columns->Items[i]->Visible = pColumn[i]->Checked;
    pIni->WriteBool(asWinName,pGrid->Columns->Items[i]->FieldName,pColumn[i]->Checked);
  }
  delete pIni;
  Close();
}
//---------------------------------------------------------------------------

void __fastcall TFormColumnSelect::FormShow(TObject *Sender)
{
  SetColumn();
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -