604
社区成员
发帖
与我相关
我的任务
分享
//请问: 1.怎么让Listview第X列文字显示特定颜色?(25)
void __fastcall TForm1::ListView1AdvancedCustomDrawItem(
TCustomListView *Sender, TListItem *Item, TCustomDrawState State,
TCustomDrawStage Stage, bool &DefaultDraw)
{
if(Item->Index==0) //0 行 (特定行)
{
ListView1->Canvas->Brush->Color = clWhite ;
ListView1->Canvas->Font->Color = clBlue; //字体为 clBlue 颜色
}
else
ListView1->Canvas->Brush->Color = clWhite;
}
void __fastcall TForm1::ListView1AdvancedCustomDrawSubItem(
TCustomListView *Sender, TListItem *Item, int SubItem,
TCustomDrawState State, TCustomDrawStage Stage, bool &DefaultDraw)
{
if(Item->Index==1)//1行
{
if(SubItem==1||SubItem==2||SubItem==3)//1、2、3列
{
ListView1->Canvas->Brush->Color = clWhite ;
ListView1->Canvas->Font->Color = clBlue; //字体为 clBlue 颜色
}
else
{
ListView1->Canvas->Brush->Color = clWhite;
ListView1->Canvas->Font->Color = clBlack; //字体为 clBlack 颜色
}
}
}
//同样 要 第0列第Y行显示特定颜色?? 加个判断
//0列1行
void __fastcall TForm1::ListView1AdvancedCustomDrawItem(
TCustomListView *Sender, TListItem *Item, TCustomDrawState State,
TCustomDrawStage Stage, bool &DefaultDraw)
{
if(Item->Index==1) //1 行
{
ListView1->Canvas->Brush->Color = clWhite ;
ListView1->Canvas->Font->Color = clBlue; //字体为 clBlue 颜色
}
}
void __fastcall TForm1::ListView1CustomDrawSubItem(TCustomListView *Sender,
TListItem *Item, int SubItem, TCustomDrawState State,
bool &DefaultDraw)
{
//还原除第一列的其它列
ListView1->Canvas->Brush->Color = clWhite;
ListView1->Canvas->Font->Color = clBlack;
}
//画第一列的用个笨方法吧
//先把所有的列画上你要的颜色,然后把除了第一列的其它列全部恢复颜色,
//这样效果就是只有第一列有颜色了
void __fastcall TForm1::ListView1AdvancedCustomDrawItem(
TCustomListView *Sender, TListItem *Item, TCustomDrawState State,
TCustomDrawStage Stage, bool &DefaultDraw)
{
//全部画上
ListView1->Canvas->Brush->Color = clWhite ;
ListView1->Canvas->Font->Color = clBlue; //字体为 clBlue 颜色
}
void __fastcall TForm1::ListView1CustomDrawSubItem(TCustomListView *Sender,
TListItem *Item, int SubItem, TCustomDrawState State,
bool &DefaultDraw)
{
//还原除第一列的其它列
ListView1->Canvas->Brush->Color = clWhite;
ListView1->Canvas->Font->Color = clBlack;
}
//2.怎么让Listview 第X列,第Y行(交汇)文字显示特定颜色?(50)?
//1行2列交汇单元格的颜色
void __fastcall TForm1::ListView1AdvancedCustomDrawSubItem(
TCustomListView *Sender, TListItem *Item, int SubItem,
TCustomDrawState State, TCustomDrawStage Stage, bool &DefaultDraw)
{
if(Item->Index==1)//1行
{
if(SubItem==2)//2列
{
ListView1->Canvas->Brush->Color = clWhite ;
ListView1->Canvas->Font->Color = clBlue; //字体为 clBlue 颜色
}
else
{
ListView1->Canvas->Brush->Color = clWhite;
ListView1->Canvas->Font->Color = clBlack; //字体为 clBlack 颜色
}
}
}
//2.怎么让Listview第Y行文字显示特定颜色?(25) ?
void __fastcall TForm1::ListView1AdvancedCustomDrawSubItem(
TCustomListView *Sender, TListItem *Item, int SubItem,
TCustomDrawState State, TCustomDrawStage Stage, bool &DefaultDraw)
{
if(SubItem==2)//2列 (特定列)
{
ListView1->Canvas->Brush->Color = clWhite ;
ListView1->Canvas->Font->Color = clBlue; //字体为 clBlue 颜色
}
else
{
ListView1->Canvas->Brush->Color = clWhite;
ListView1->Canvas->Font->Color = clBlack; //字体为 clBlack 颜色
}
}