Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

LmdGrid Column Chooser

Hi
I am looking for an example to fill a PickList in a LMDGrid Column at runtime.

The Chooser Items property is not accessible at runtime.

The LMDGridDemo.exe from here (where maybe an example is included)


is faulty: 

Lmdgriddemo
Invalid parameter.
OK   

Thanks for your help

Sorry for the confusion, I already posted this question to an old done post, I think that's not quite right.

Comments

  • 2 Comments sorted by Votes Date Added
  • The link, provided by you, pointing to the compiled version of the demo, which does not include source code. Demo sources can be found in the corresponding demo folder of your installation.

    To access specific properties of a Chooser at run-time, you need to case the chooser to its exact class:

    (MyColumn.Chooser as TLMDGridPickListChooser).Items.Add('...');


    Additionally, if you need non-numeric values in the drop-down list of the numeric column, you can follow the way, shown in the demo:

    The demo contains TLMDGrid with a column of floating point mubers. The Chooser is set to PickList, Chooser.Items is set to a set of values, including nonnumeric values, like Pi or Exp:

    1
    3
    5
    7
    PI
    EXP

    To handle these values two event handlers are written:

    procedure TMainForm.LMDGridFloatColumn1FloatFormatEdit(Grid: TObject;
      Column: TLMDGridColumn; const Value: Variant;
      AIsNull: Boolean; var S: string);
    var
      d: Double;
    begin
      if not AIsNull then
      begin
        d := Value;
        if Abs(3.14 - d) <= 0.0001 then
          S := 'PI'
        else if Abs(2.76 - d) <= 0.0001 then
          S := 'EXP';
      end;
    end;

    procedure TMainForm.FloatColParse(Grid: TObject; Column: TLMDGridColumn;
      const S: string; var Value: Variant; var ParsedOk: Boolean;
      CanRaiseError: Boolean);
    begin
      if UpperCase(S) = 'PI' then
      begin
        Value := 3.14;
        ParsedOk := True;
      end
      else if UpperCase(S) = 'EXP' then
      begin
        Value := 2.76;
        ParsedOk := True;
      end
      else if not ParsedOk then
        raise Exception.Create('Only float values or "PI"/"EXP" constants allowed!');
    end;

    The first even handler is connected to OnFormatEdit and OnFormatPaint events, while the second - to OnParse event.
  • Thanks for extensive examples and hints. This helps me a lot
Sign In or Register to comment.