【问题标题】:TMS TPlannerMonthView: get selected item textTMS TPlannerMonthView:获取所选项目文本
【发布时间】:2021-09-08 11:33:47
【问题描述】:

我是 Delphi 的新手,我正在尝试从我在 Planner 中选择的项目中获取名称。使用PlannerMonthView1.CreateItem 后设置项目的文本,如下所示:

  DbDate := FrmMain.FDTable1.FindField('NOT_DATE').AsFloat;
  FrmMain.FDTable1.First;
  for i := 0 to FrmMain.ListBox1.Count-1 do
  begin
    With PlannerMonthView1.CreateItem do
    begin
      DbDate := FrmMain.FDTable1.FindField('NOT_DATE').AsFloat;
      ItemStartTime := DbDate;
      ItemEndTime := DbDate;
      Text.Text := FrmMain.FDTable1.FindField('NOT_NAME').AsString;
      FrmMain.FDTable1.Next;
    end;

我的问题是 TMS 中没有针对 Planner 工具的组件列表。我试过这样:

ShowMessage(FKalender.PlannerMonthView1.CreateItem.Text.GetText[2]);

...但显示的是一个空的消息框。

【问题讨论】:

  • 属性选择:TPlannerItem;返回当前选定的项目。手册中的所有内容:tmssoftware.biz/Download/Manuals/TMS%20TPLANNER.pdf 查找“计划器中的项目选择”
  • 嗨,那是您的帮助。但现在我有另一个问题。我已经尝试过:Text := PlannerMonthView1.Items.Select; 但这并不是因为“没有足够的真实参数”

标签: delphi tms


【解决方案1】:

(构造函数)方法名称.CreateItem() 不是为了好玩:它确实创建了一个新项目。为什么不将其分配给变量?

var
  myPlannerItem: TPlannerItem;
begin
  myPlannerItem:= PlannerMonthView1.CreateItem();
  ...
  // Accessing the item's text (all lines at once)
  ShowMessage( myPlannerItem.Text.Text );
  ...
  // Unrelated to the one we've added: show the currently selected item's
  // 3rd line of its text
  ShowMessage( PlannerMonthView1.Selected.Text[2] );
  ...
  // The documentation http://www.tmssoftware.biz/download/manuals/TMS TPLANNER.pdf
  // around page 96 instructs you to use the Planner to delete the item instead
  // of freeing the object itself
  PlannerMonthView1.FreeItem( myPlannerItem );

请注意,这不是一个“名称”,而是一个变量。 with 的使用应该减少到最低限度,并且只有在您以后不需要访问新创建的对象时才有意义。

ShowMessage(FKalender.PlannerMonthView1.CreateItem.Text.GetText[2]);

这不会显示任何文本,因为您刚刚通过 .CreateItem() 创建了另一个新项目,而不是访问任何以前创建的项目,因此其所有属性都有其默认值(.Text 为空)。

【讨论】:

  • 好的,我明白了。但是 PlannerMonthView1.Text 没有 .Text 对不起,我可能有点迷失了,但我已经用 Selected Methode 尝试过,但这对我也不起作用。文本:= PlannerMonthView1.Items.Select(Item);给我错误“不兼容的类型'String'和'procedure'”
  • 选择一个项目和想知道当前选择了什么是两件不同的事情:过程Select()不能分配给Text类型的变量String。我已经编辑了我的答案以包含更多示例。也请拨打tour
猜你喜欢
  • 2021-12-22
  • 1970-01-01
  • 2012-11-16
  • 2011-09-19
  • 1970-01-01
  • 1970-01-01
  • 2011-06-19
  • 2016-05-25
  • 2012-06-22
相关资源
最近更新 更多