//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "CustomGridView"
#pragma link "CustomGridViewControl"
#pragma link "GridView"
#pragma link "ScrollView"
#pragma link "CellEditors"
#pragma link "GridPrint"
#pragma link "NxColumnClasses"
#pragma link "NxColumns"
#pragma link "NxCustomGrid"
#pragma link "NxCustomGridControl"
#pragma link "NxEdit"
#pragma link "NxGrid"
#pragma link "NxGridPrint"
#pragma link "NxScrollControl"
#pragma resource "*.dfm"
TForm1 *Form1;

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
        GridView1->AddRow(3);

        GridView1->Cell[1][0]->AsString = "Use Disks from office";
        GridView1->Cell[2][0]->AsDateTime = Today();
        GridView1->Cell[3][0]->AsInteger = 0;
        GridView1->Cell[4][0]->AsInteger = 2;

        GridView1->Cell[1][1]->AsString = "Go to Mike";
        GridView1->Cell[2][1]->AsDateTime = Tomorrow();
        GridView1->Cell[3][0]->AsInteger = 1;
        GridView1->Cell[4][1]->AsInteger = 1;
        GridView1->Cell[5][1]->AsString = "not <i>realy</i> important";

        GridView1->Cell[1][2]->AsString = "Pay a Bills";
        GridView1->Cell[2][2]->AsDateTime = Today();
        GridView1->Cell[3][0]->AsInteger = 1;
        GridView1->Cell[4][2]->AsInteger = 3;
        GridView1->Cell[4][2]->Hint = "Don't forget";
        GridView1->Cell[5][2]->AsString = "this is <b><font color=#990000>very</font></b> <i>important</i>";

        StatusBar1->Panels->Items[0]->Text = "3 Rows Added";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Exit1Click(TObject *Sender)
{
        Close();        
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Default1Click(TObject *Sender)
{
        GridView1->HeaderStyle = hsAuto;        
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Flat1Click(TObject *Sender)
{
        GridView1->HeaderStyle = hsFlatBorders;        
}
//---------------------------------------------------------------------------

void __fastcall TForm1::OldStyleMSAccess1Click(TObject *Sender)
{
        GridView1->HeaderStyle = hsOldStyle;        
}
//---------------------------------------------------------------------------

void __fastcall TForm1::SpinEditor1Change(TObject *Sender)
{
        GridView1->RowSize = SpinEditor1->AsInteger;        
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
        SpinEditor1->AsInteger = GridView1->RowSize;        
}
//---------------------------------------------------------------------------

void __fastcall TForm1::GridView1SelectCell(TObject *Sender, int ACol,
      int ARow)
{
        StatusBar1->Panels->Items[1]->Text = "Selected Cell: " + IntToStr(ACol) + ", " + IntToStr(ARow);
        StatusBar1->Panels->Items[2]->Text = "Cell Value: " + GridView1->Cells[ACol][ARow];
        ColorPickerEditor1->SelectedColor = GridView1->Cell[ACol][ARow]->Color;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::GridView1FooterClick(TObject *Sender, int ACol)
{
        if (ACol == 3)
        {
                GridView1->CalculateFooter();
        }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)
{
        if (SaveDialog1->Execute())
        {
                GridView1->SaveToTextFile(SaveDialog1->FileName);
        }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Print1Click(TObject *Sender)
{
        if (PrintDialog1->Execute())
        {
                GridPrint1->Print();                
        }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ColorPickerEditor1Change(TObject *Sender)
{
        GridView1->Cell[GridView1->SelectedColumn][GridView1->SelectedRow]->Color = ColorPickerEditor1->SelectedColor;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::SellectAll1Click(TObject *Sender)
{
        GridView1->SelectAll();        
}
//---------------------------------------------------------------------------

void __fastcall TForm1::SelectFullRow1Click(TObject *Sender)
{
        if (SelectFullRow1->Checked)
        {
                GridView1->Options = GridView1->Options << goSelectFullRow;
        } else
        {
                GridView1->Options = GridView1->Options >> goSelectFullRow;
        }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::MultiSelect1Click(TObject *Sender)
{
        if (MultiSelect1->Checked)
        {
                GridView1->Options = GridView1->Options << goMultiSelect;
        } else
        {
                GridView1->Options = GridView1->Options >> goMultiSelect;
        }        
}
//---------------------------------------------------------------------------

void __fastcall TForm1::SelectNone1Click(TObject *Sender)
{
        GridView1->NoSelection();        
}
//---------------------------------------------------------------------------

