Wo ist der Cursor?



  • In eine TStringGrid Komponente setze ich einige Spalten als schreibbar und einige Spalten als nur lesbar. Das Problem ist: der Cursor ist immer unsichtbar, wenn er in einer beschreibbaren Zelle steht. Ich verstehe es echt nicht wieso? Weil ich die Method "setCellEditable" auch für eine andere TStringGrid Komponent benutze, und der Cursor sichtbar ist, wenn er in einer beschreibbaren Zelle steht. Kann jemand mein Code mal überprüfen und mir einen tipp geben? Danke!

    //---------------------------------------------------------------------------
    void __fastcall TF_Option::SG_OperatorDrawCell(TObject *Sender, int ACol,
          int ARow, TRect &Rect, TGridDrawState State)
    {
        if (ARow != 0)
        {
            if (_ifCheckedO[ACol][ARow] == true)		// ifCheckedO is a parameter for selected or unselected
            {
                SG_Operator->Canvas->Brush->Color = (TColor)0x00D5C7BF;      //Set background
                SG_Operator->Canvas->Font->Color = getOperatorColor(ACol, ARow);
            }
            else
            {
                SG_Operator->Canvas->Brush->Color = (TColor)0x00FFFDFD;      //Set background of cell white
                SG_Operator->Canvas->Font->Color = getOperatorColor(ACol, ARow);
            }
    
            SG_Operator->Canvas->FillRect(Rect);
            SG_Operator->Canvas->TextRect(Rect, Rect.Left+1, Rect.Top, SG_Operator->Cells[ACol][ARow]);
    
            if (State.Contains(gdFocused))
            {
                SG_Operator->Canvas->DrawFocusRect(Rect);
            }
        }
        else
        {
            SG_Operator->Canvas->TextRect(Rect, Rect.Left+1, Rect.Top, SG_Operator->Cells[ACol][ARow]); //mo+2
        }
    }
    
    //---------------------------------------------------------------------------
    void __fastcall TF_Option::SG_OperatorSelectCell(TObject *Sender, int ACol,
          int ARow, bool &CanSelect)
    {
        if (ARow > 0 && SG_Operator->Cells[ACol][ARow] != "")
        {
            UtilitiesTStringGrid *utils = F_Main->getUtilityManager()->getUtilitiesTStringGrid();
            if (ACol == 2 || ACol == 3 || ACol == 6 || ACol == 7)		// Column 2, 3, 6, 7 are editable and cursor should be displayed in these cells
            {
                utils->setCellEditable(SG_Operator, true);
            }
            else								// the rest of columns are only readable
            {
                utils->setCellEditable(SG_Operator, false);
                bool status = _ifCheckedO[ACol][ARow];
                int ind = ACol / 4;
                for (int i=ind*4; i<ind*4+4; i++)
                {
                    _ifCheckedO[i][ARow] = !status;
                }
            }
    
            SG_Operator->Refresh();
        }
    }
    
    //---------------------------------------------------------------------------
    void UtilitiesTStringGrid::setCellEditable(TStringGrid *sg, bool status)
    {
        if (!status)
            sg->Options = TGridOptions()<<goFixedVertLine<<goFixedHorzLine<<goVertLine<<goHorzLine<<goTabs;
        else
            sg->Options = TGridOptions()<<goFixedVertLine<<goFixedHorzLine<<goEditing<<goVertLine<<goHorzLine<<goTabs<<goAlwaysShowEditor;
    }
    

Anmelden zum Antworten