StringGrid控件如何加上checkbox,button???最好给代码!

StringGrid控件如何加上checkbox,button???最好给代码!,第1张

Left:=ARect.Left+1先在GRID琅绫擎放入一个BUTTON在ONSELECTCELL事宜中写代码,根据事宜的参数,你可以获得当前CELL的宽度,和高度,既ARect:TRectwith

Button

dobegin

Top:=ARect.Top+1

Width:=ARect.Right-ARect.Left+1

Height:=ARect.Bottom-ARect.Top+1

Visible:=True

SetFocus

end

试试这个能不能实现,通过自画的方式在单元格内画出文字控件使用-StringGrid多行显示超长文字void__fastcallTForm1::StringGrid1DrawCell(TObject*Sender,intACol,intARow,TRect&Rect,TGridDrawStateState){TRectARect//paintcellrangeARect=StringGrid1->CellRect(ACol,ARow)AnsiStringCurrStr=StringGrid1->Cells[ACol][ARow]if(CurrStr.Length()Canvas->Brush->Color=clRed//SettingCellcolor//StringGrid1->Canvas->FillRect(ARect)//StringGrid1->Canvas->Font->Color=clBlack//SettingCellContentsFontColorStringGrid1->Canvas->TextRect(ARect,ARect.Left+2,ARect.Top+2,StringGrid1->Cells[ACol][ARow])}else{//StringGrid1->Canvas->Brush->Color=clWhite//StringGrid1->Canvas->FillRect(ARect)//StringGrid1->Canvas->Font->Color=clBlackStringGrid1->Canvas->TextOut(ARect.Left+2,ARect.Top+2,StringGrid1->Cells[ACol][ARow].SubString(1,10))StringGrid1->Canvas->TextOut(ARect.Left+2,ARect.Top+17,StringGrid1->Cells[ACol][ARow].SubString(11,20))}}


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/7895719.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-11
下一篇2023-04-11

发表评论

登录后才能评论

评论列表(0条)

    保存