TAdvListView的颜色显示问题

sxqinge 2012-08-01 03:22:55
我不断的往表格中添加数据,并对不同的数据进行颜色处理,比如对异常数据的单元格背景填充为红色。
现在的问题是,
只要我界面一刷新,比如将界面给最小化,然后最大化一下,或者是数据过多将会有滚动条出现时,奇异的事情就出现了,第一列有数据填充的单元格全部变为红色,如果再次刷新一下,部分红色会消失,但是第一个单元格随便你怎么刷新,它肯定是红色。
请问这是什么原因呢?我该怎么解决?
...全文
150 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
sxqinge 2012-08-07
  • 打赏
  • 举报
回复
现在论坛似乎活跃了不少,帖子几天没顶居然被落到第二页了。
继续等热心大虾解疑答惑,谢谢。
sxqinge 2012-08-02
  • 打赏
  • 举报
回复
自己顶下,代码虽然难看,还望热心高手给予指点,真诚谢谢。
sxqinge 2012-08-01
  • 打赏
  • 举报
回复

1.数据添加函数
void TfrmMain::AddDatas(TAdvListView* lv, const AnsiString Str, int &Value)
{
int Port = Str.ToIntDef(0);
if( Port <= 0 ) return;
if( m_CommForms[Port]->MeasValue == Value ) return;
Value = m_CommForms[Port]->MeasValue; // 这里是获取采集数据
m_Error[Port] = m_CommForms[Port]->m_Error; //m_Error为异常标识

static int tt = 0;
int Row = lv->Items->Count-1;
TListItem* Item = lv->Items->operator [](Row);
if( NULL == Item ) {
Item = lv->Items->Add(); Item->Caption = tt++;
for( int i=0; i<10; i++ ) Item->SubItems->Add("-1");
}
else {
if( Item->SubItems->Strings[9] != "-1" ) {
Item = lv->Items->Add(); Item->Caption = tt++;
for( int i=0; i<10; i++ ) Item->SubItems->Add("-1");
// 上一句,本来想用Item->SubItems->Add("");结果发现添加不成功,
// 如果后面直接往SubItem里填入数据会报错,指针溢出;
}
}

AnsiString tmp = IntToStr(Value);
for( int i=0; i<10; i++ )
{
if( Item->SubItems->Strings[i] != "-1") continue;
Item->SubItems->Strings[i] = tmp;
break;
}
}

2.添加过程函数
void __fastcall TfrmMain::lvList1AdvancedCustomDrawSubItem(
TCustomListView *Sender, TListItem *Item, int SubItem,
TCustomDrawState State, TCustomDrawStage Stage, bool &DefaultDraw)
{
SubItem -= 1;
static int temp = 0;
if( m_Start[0] ) {temp = Item->SubItems->Strings[SubItem].ToInt()-1;m_Start[0]=false;}
int Port = edtMeter1->Text.ToIntDef(0);
SubItemDrawFun(Sender,temp,Item,SubItem,DefaultDraw, m_Error[Port]);
}

void TfrmMain::SubItemDrawFun( TCustomListView *Sender, int &pData,
TListItem *Item, int SubItem, bool &DefaultDraw, bool bFlag)
{
Sender->Canvas->Brush->Color = clInfoBk;
int data = Item->SubItems->Strings[SubItem].ToInt();
if( bFlag ) Sender->Canvas->Brush->Color = clLime;
else {
int K0 = (int)(abs(data-pData)+0.5);
if( K0 != RIGHTVALUE ) Sender->Canvas->Brush->Color = clRed; // #define RIGHTVALUE 1
}

pData = data;
DefaultDraw = true;
}
Jim@luckeeinc.com 2012-08-01
  • 打赏
  • 举报
回复
TMS我也一直在用,还算稳定,不过有的控件确实有一些问题
比如AdvColumnGrid在填了数据后,对某一个单元格的数据修改后update数据库再刷新,居然单元格会变成空的要刷新两次...
LZ的说的控件没用过,如果确实不是程序问题造成的,自己想办法处理吧..看看AdvancedCustomDraw或者OnData这些事件里能不能处理把改颜色写到这些事件里来
ccrun.com 2012-08-01
  • 打赏
  • 举报
回复
上代码,看看再说。
v10.5.5.0 New : function NumSuppressedRows: integer added in TAdvStringGrid New : TAdvSmoothRotaryMenu BackgroundPicture implemented New : Head property added to TAdvRichEditorHTMLIO New : BodyClass property added to TAdvRichEditorHTMLIO New : AutoSize property added in TAdvGraphicCheckLabel Improved : Wait cursor handling in TWebUpdate wizard Improved : SortIndexes.Clear updates sort indicators Improved : Added AIncludeRows parameter to XYToColumn to include rows while detecting which column is located at X and Y coordinate in TAdvTreeView Fixed : TAdvSmoothExpanderPanel Height set when MinimumPanelHeight used in runtime creation Fixed : Regression with stricter date format checking in TAdvStringGrid Fixed : Rare issue with threading in TAdvSmartMessageBox() Fixed : Memory leak issue in TTreeList Fixed : Issue with vertical text align in TAdvTreeView Fixed : Issue with scrolling while list is not visible in TAdvGridDropDown Fixed : Issue with repainting speed buttons on TAdvSpinEdit with VCL styles Fixed : Issue with font color in combination wwith code block caption in TAdvCodeList Fixed : Issue with changing Enabled at design-time in TAdvSpinEdit Fixed : Issue with boolean filters for non-English Delphi in TDBAdvFilterPanel Fixed : Issue with badge positioning on buttons on ribbon Fixed : Issue with VCL styles based rendering in THTMLHint Fixed : Issue with TDBItemSource initialization Fixed : Issue when doing custom sort in Win64 in TAdvListView Fixed : Issue in TAdvSmoohtListBox with initializing time when using VCL styles Fixed : DPI calculation when parent form is not Scaled
Update : TSectionListBox v1.9.2.8 --------------------------------- - Fixed : Issue with spurious horz. scrollbar Update : T(DB)Planner v3.0.3.4 ------------------------------ - Fixed : Issue with HasItem() and selected items Update : TAdvStringGrid 7.0.3.0 ------------------------------- - New : Extra parameter added for grid.ScrollInView to define scroll position better - Improved : Handling of VCL styles - Fixed : Issue with Combobox inplace editor & grid OnKeyDown event - Fixed : Issue with OnKeyDown event handler when Ctrl-Enter is pressed and AllowCtrlEnter = false Update : TAdvSmoothMegaMenu v1.3.5.1 ------------------------------------ - New : Hiding Sections - Fixed : Issue with hiding items Update : TMS ToolPanels v1.5.6.2 -------------------------------- - Fixed : Issue with form's OnShow event handling Update : TAdvSmoothPanel v1.3.0.1 --------------------------------- - Fixed : Do not set size of the shadow as part of the style Update : TAdvSmoothExpanderPanel v1.0.4.2 ----------------------------------------- - Fixed : Issue with use of CanMove and expander button Update : TAdvSmoothSlideShow v1.3.0.0 ------------------------------------- - New : Events when animation of a placeholder / image is processing / finished - New : OnDrawPlaceHolder event Update: TAdvListEditor v1.1.0.2 ------------------------------- - Fixed : Issue with OnKey* event handling Update : TAdvGlowButton v2.2.2.0 -------------------------------- - Improved : Use of MarginHorz in combination with Layout = blGlyphLeftAdjusted Update : TAdvEdit v3.1.1.1 -------------------------- - Fixed : Issue with CharCase <> ecNormal and use of Prefix Update : TDBAdvGrid v2.3.6.0 ---------------------------- - New : Automatic display of memo fields in HTML template columns Update : TAdvPreviewMenu v5.0.4.1 --------------------------------- - Improved : Tab key handling Update : TAdvOutlookList v1.7.7.1 --------------------------------- - Fixed : Issue with reordering columns in TAdvOutlookList Update : TAdvMemo v3.1.2.1 -------------------------- - Fixed : Issue with context menu handling Update : TAdvListView v1.6.9.3 ------------------------------ - Fixed : Issue with Item index for OnLeftClickCell/OnRightClickCell events

604

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder VCL组件使用和开发
社区管理员
  • VCL组件使用和开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧