0

In my grid in one of my columns I have set CheckComboxBox to it's property. The problem is I'm not able to fill it's Items programmatically.

Using

void __fastcall TfPln::tvDepACGetProperties(TcxCustomGridTableItem *Sender,
          TcxCustomGridRecord *ARecord, TcxCustomEditProperties *&AProperties)

{
    AProperties=cxCheckComboBox1->Properties;
}

but my form freezes ! My goal is to fill that column with data from a dataset on Form create event so I even do not reach column's Items property!

I am asking what's the possible way to fill Grid's TcxCheckCombobox Items???

I have a delphi code which do this

procedure TForm1.FormCreate(Sender: TObject);
begin
  with Table1 do
  begin
    DisableControls;
    First;
    while not Eof do
    begin

TcxCheckComboBoxProperties(cxGrid1DBTableView1Company.Properties).Items.AddC
heckItem(FieldByName('Company').AsString);
      Next;
    end;
    First;
    EnableControls;
  end;
end;

The line which fills items TcxCheckComboBoxProperties(cxGrid1DBTableView1Company.Properties).Items.AddC heckItem(FieldByName('Company').AsString); right??

in c++ I use TcxCheckComboBoxProperties(tvDepAC->Properties) but when I try to call Items property there isn't such property! That's TcxCheckComboBoxProperties(tvDepAC->Properties)->Items.AddCheckItem(i) is not correct!!

What could be the problem??

need help !!!

RRUZ
  • 134,889
  • 20
  • 356
  • 483
Suhrob Samiev
  • 1,528
  • 1
  • 25
  • 57
  • Not sure exactly what the problem is but a few things might help, depending on how large the Table1 recordset is: 1) use cxGrid1DBTableView1.BeginUpdate and EndUpdate so your UI doesn't go through refreshes for each iteration of the while loop, 2) get rid of the type casting inside the while loop (set a local variable instead), and 3) don't use FieldByName inside the while loop (a local variable avoids repeated lookups in the field list). – Sam M Apr 01 '12 at 04:00

1 Answers1

0

In what mode do you use the grid ? There are 3 possibilities (from the doc)

  • Bound mode

The DataController is connected to a TDataSet by means of a TDataSource object.

  • Provider mode

The DataController is connected to a user-defined (custom) data source and data is requested as needed.

  • Unbound mode

The data controller is not connected to a data source and is pre-populated with records manually.

With Bound mode your grid is filled automatically from your sql statement. If you want more control in code you use provider mode. For example you can load data from textfiles. Use Unbound control to add any data to the grid.

Roland Bengtsson
  • 5,058
  • 9
  • 58
  • 99
  • in `bound` mode as I've linked it to a datasource. For the time being I am using it's RepositoryItem property that will be applied to the entire row. How to do it in runtime?? [using EQGrid 6.52 and] and be able to reach its `Items` property and CheckStates? – Suhrob Samiev Apr 01 '12 at 07:46
  • here is a screenshot http://www.flickr.com/photos/67246820@N08/6888244562/in/photostream – Suhrob Samiev Apr 01 '12 at 07:59
  • So you problem is that you have Delphi code that cannot be translated to C++ ? In that case I'm afraid I cannot help you because I only use Delphi with Devexpress. Try ask Devexpress on www.devexpress.com/Support/Center. – Roland Bengtsson Apr 01 '12 at 12:06
  • Found this project with Google where AddCheckItem is used. Maybe it can help... http://code.google.com/p/evaluatedecks/source/browse/trunk/src/API/EvaluateDecksSrc.pas?r=71 – Roland Bengtsson Apr 01 '12 at 14:18
  • Thanks Roland! I'll check it out! Nice resource. – Suhrob Samiev Apr 01 '12 at 16:52
  • Casting helped! From the startup I knew that it was a casting problem! When i typed `dynamic_cast(tvDepAC->Properties)->` and unexpectedly come out an Items property, then added `Items->AddCheckItem(DM->tAC->AsString);` Casting in delphi is not explicit as I think.. – Suhrob Samiev Apr 01 '12 at 17:13
  • Now I can add items dynamically not statically! :) – Suhrob Samiev Apr 01 '12 at 17:21