⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mymainform.pas

📁 本产品是开发LISTVIEW相关功能的可定制产品
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    if (i mod 10)=2 then
       ShowDataBuffer[0] := '2'; //第一个值是专门为状态图标显示用的,用于保存状态序号
    if (i mod 10)=3 then
       ShowDataBuffer[0] := '3'; //第一个值是专门为状态图标显示用的,用于保存状态序号
    if (i mod 10)=4 then
       ShowDataBuffer[0] := '4'; //第一个值是专门为状态图标显示用的,用于保存状态序号
    if (i mod 10)=5 then
       ShowDataBuffer[0] := '5'; //第一个值是专门为状态图标显示用的,用于保存状态序号
    if (i mod 10)=6 then
       ShowDataBuffer[0] := '6'; //第一个值是专门为状态图标显示用的,用于保存状态序号
    if (i mod 10)=7 then
       ShowDataBuffer[0] := '7'; //第一个值是专门为状态图标显示用的,用于保存状态序号
    if (i mod 10)=8 then
       ShowDataBuffer[0] := '8'; //第一个值是专门为状态图标显示用的,用于保存状态序号
    if (i mod 10)=9 then
       ShowDataBuffer[0] := '9'; //第一个值是专门为状态图标显示用的,用于保存状态序号

    ShowDataBuffer[1] := inttostr(i)+ '111分句名称';
    ShowDataBuffer[2] := inttostr(i)+ '222硬件编码';
    ShowDataBuffer[3] := inttostr(i)+ '333RTU 名称';
    ShowDataBuffer[4] := inttostr(i)+  '444路号';
    ShowDataBuffer[5] := inttostr(i)+ '555锁编号';
    ShowDataBuffer[6] := inttostr(i)+  '666人孔编号';
    ShowDataBuffer[7] := inttostr(i)+  '777人孔名称';
    ShowDataBuffer[8] := inttostr(i)+  '888管孔编号';
    ShowDataBuffer[9] := inttostr(i)+  '999外盖编号';
    ShowDataBuffer[10] := inttostr(i)+ '10交接箱编号';
    ShowDataBuffer[11] := inttostr(i)+ '11交接箱地址';
    ShowDataBuffer[12] := inttostr(i)+ '12交接箱端子';
//    ShowDataBuffer[13] := inttostr(i)+ '13状态历时';
    FList.Add(ShowDataBuffer);
  end;
  Result := true;
end;

procedure TmyMainForm1.CSListViewData(Sender: TObject; Item: TListItem);
var
  p: PListData;
begin
  P :=DisplayClass.ShowListView(CSListView,Item,FList);//参数传递,并命令显示,CustomDisplay.是已经赋有显示数据的值
  item.Data := p;//递归调用
end;

procedure TmyMainForm1.BitBtn1Click(Sender: TObject);
begin
  if LoadSelectToShowBuffer=true then
    CustomDisplay.RefreshListview(CSListView,FList);//调用刷新函数进行显示

end;

procedure TmyMainForm1.BitBtn2Click(Sender: TObject);
begin
   ClearList(FList);
   CSListView.Clear;

end;

procedure TmyMainForm1.N8Click(Sender: TObject);
var
   I,J:Integer;
   s1:string;
begin
  i:=10;
  J:=1;
  s1:='第2和3列变更2';
  CustomDisplay.ChgRowInPosition(FList,i,J,s1);
  J:=2;
  s1:='第2和3列变更3';
  CustomDisplay.ChgRowInPosition(FList,i,J,s1);
  CustomDisplay.RefreshListview(CSListView,FList);//各列更新后统一刷新显示
  StBar.Panels[1].Text:='修改信息成功';
  WriteLog(Memo1,'修改信息成功');
end;

procedure TmyMainForm1.N7Click(Sender: TObject);
var
  i:Integer;
begin
  i:=15;
  new(ShowDataBuffer);
   //初始化
  ShowDataBuffer[0] := '1'; //第一个值是专门为状态图标显示用的,用于保存状态序号
  ShowDataBuffer[1] := inttostr(i);
  ShowDataBuffer[2] := inttostr(i);
  ShowDataBuffer[3] := inttostr(i);
  ShowDataBuffer[4] := inttostr(i);
  ShowDataBuffer[5] := inttostr(i);
  ShowDataBuffer[6] := inttostr(i);
  ShowDataBuffer[7] := inttostr(i);
  ShowDataBuffer[8] := inttostr(i);
  ShowDataBuffer[9] := inttostr(i);
  ShowDataBuffer[10] := inttostr(i);
  ShowDataBuffer[11] := inttostr(i);
  ShowDataBuffer[12] := '12交端';
//  ShowDataBuffer[13] := inttostr(i);
//  ShowDataBuffer[14] := '分局ID编号';
  FList.Add(showDataBuffer);  //首先添加到显示数据列表的最后面

  //从CList列表中的第nPosition行(位置)开始,所有行向后面移一行,最后一行数据丢弃
  CustomDisplay.ShiftRowToBack(i,FList);
  FList[i]:=ShowDataBuffer;

  CustomDisplay.RefreshListview(CSListView,FList);//调用刷新方法
  StBar.Panels[1].Text:='在第15行后添加信息成功';
  WriteLog(Memo1,'在第15行后添加信息成功');
end;

procedure TmyMainForm1.N9Click(Sender: TObject);
var
  i:Integer;
begin
   i:=12;
   DisplayClass.DeleteRow(i,FList);      //调用删除行方法
   CustomDisplay.RefreshListview(CSListView,FList);//调用刷新方法
   StBar.Panels[1].Text:='删除第13行信息成功';
   WriteLog(Memo1,'删除第13行信息成功');
end;



//点击标题列的排序实现,如果各名称定义相同,该代码可以复用
procedure TmyMainForm1.CSListViewColumnClick(Sender: TObject;
  Column: TListColumn);

  function SortList(Item1, Item2: Pointer): Integer;
  var
      V1, V2: TShowDataBuffer;
      i,a,b:integer;
      Dt1,Dt2:Tdatetime;
  begin
      V1 := TShowDataBuffer(Item1^);
      V2 := TShowDataBuffer(Item2^);
      if HaveSort[FColumnIndex] then i:=1
      else i:=-1;
      if FDataType=0 then//如果是数字型
      begin
         if v2[FIndex]='' then a:=0
         else a:=strtoint(v2[FIndex]);
         if v1[FIndex]='' then b:=0
         else b:=strtoint(v1[FIndex]);
         Result := i*CompareValue(a, b);
      end
      else if FDataType=1 then//如果是字符(串)型
         Result := i*CompareText(v2[FIndex], v1[FIndex])
      else if FDataType=2 then//如果是日期时间型
      begin
         if v2[FIndex]='' then Dt1:=now-3000
         else Dt1:=strtoDatetime(v2[FIndex]);
         if v1[FIndex]='' then Dt2:=now-3000
         else Dt2:=strtoDatetime(v1[FIndex]);
         Result := i*CompareDateTime(Dt1, Dt2);
      end;
  end;
begin
  FColumnIndex:=Column.Index;
  HaveSort[FColumnIndex] := Not HaveSort[FColumnIndex];
  FIndex :=DisplayClass.colum[Column.Index];
  FDataType:=DisplayClass.aDataType[Column.Index];
  FList.Sort(@SortList);
  CustomDisplay.RefreshListview(CSListView,FList); //将排序后的内容重新显示到LISTVIEW
end;

//sCustomshow:是否需要定制打印
//sFormCaption:窗体名称
//sBname:
//UserName:登录用户名称
//cClass:所在窗体
//bAllPreviewNew:是否打印统计明细
//flist:所在窗体Listview
//sgNormal:所在窗体Tstringlist
//mMemo:所在窗体备注信息
procedure TmyMainForm1.BitBtn6Click(Sender: TObject);//报表打印的演示程序
var sReprotName,sFormCaption,sBname,UserName:string;
begin
  sFormCaption:='Demo';//本窗体CAPTION
  sBname:='报表副标题';
  sReprotName:=CDM.GetReportName(sFormCaption);//通过数据库获取该窗体对应报表的名称
  UserName:='制表人';
    //自定义报表打印
  sReprotName:=CDM.GetReportName(sFormCaption);
  MakeReportDetail:=TMakeReportDetail.Create;//创建报表
  MakeReportDetail.DoOnlyDetailPreviewNew(myMainForm1,FList,sReprotName,//调用报表生成方法并传递参数
          '','',sFormCaption,sBname,sReprotName,UserName,//数据库名和会话名都可以置空
          Date(),TQRPaperSize(9),Memo1);
  MakeReportDetail.Free;
  WriteLog(Memo1,'打印报表');
end;

//调用通用版本显示程序
procedure TmyMainForm1.N11Click(Sender: TObject);
var    vMemo:TMemo;
begin
  vMemo:=nil;
  if not Assigned(frmVersion) then
    frmVersion := TfrmVersion.Create(nil);
  frmVersion.ShowVer(Application.exeName);
  frmVersion.Show;
  WriteLog(Memo1,'显示版本信息');
end;

procedure TmyMainForm1.CSListViewDblClick(Sender: TObject);
var I:Integer;
begin
  for I := 0 to CSListView.Items.Count -1 do
  begin
    if CSListView.Items.Item[I].Selected then
    begin
        WriteLog(Memo1,CSListView.Items.Item[I].SubItems[0]+'SubItemImages='+inttostr(CSListView.Items.Item[I].SubItemImages[4]));
      Exit;
    end;
  end;
end;

procedure TmyMainForm1.CSListViewCustomDrawItem(Sender: TCustomListView;
  Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
//哪怕是空也必须有
end;

procedure TmyMainForm1.Memo1DblClick(Sender: TObject);
var s:Tstrings;
begin
   s:=getIPs;
   WriteLog(Memo1,'本机IP地址='+s.Text );
end;

procedure TmyMainForm1.FormDestroy(Sender: TObject);
begin
  CDM.Destroy;
  DisplayClass.Destroy;
end;

procedure TmyMainForm1.N25Click(Sender: TObject);
begin
  if not Assigned(FrmSelectColor) then
    FrmSelectColor := TFrmSelectColor.Create(nil);
  ShowColor(myMainForm1);
  FrmSelectColor.ShowModal;
  FrmSelectColor.Free;
  FrmSelectColor := nil;
  ShowColor(myMainForm1);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -