Ticket T223862
Visible to All Users

How to set TcxGrid column's Properties at runtime.

created 10 years ago

I have a base form that contains a TcxGrid. Then, I have several forms inheriting from this base class, each one connected to a different dataset.
The grid displays the raw data, some fields in some tables contain rich text format.
What is happening is that these fields in the grid are displaying the rich text formatting instead of the value.
I need to be able to set at runtime, cxGrid1DBTableView1FieldName.Properties = RichText if FieldName is a field that contains RTF.
I know how to do that at design time, but I need help doing it at runtime.

Answers approved by DevExpress Support

created 10 years ago

Hello Ernesto,

You can see the A1097: How to set an item's Properties at runtime Knowledge Base article describing how to set an in-place editor to a Grid column at runtime.

    Comments (1)
    ER ER
    Ernesto Rodriguez 6 10 years ago

      Thank you. The article point me in the right direction.
      In my case, so far, the only thing I need is to be able to display RTF fields.
      This is what I did:
      Add "cxRichEdit" to the uses clause.
      procedure TForm1Dataset1AfterOpen(DataSet: TDataSet);
      var
       i: integer;
       LColumn: TcxGridDBColumn;
       LFieldName: string;
      begin
       cxGrid1DBTableView1.ClearItems;
       cxGrid1DBTableView1.DataController.CreateAllItems();
       //GetGridConfig; //This is a routine that reads a Grid's previously saved configuration (Visible, length, position of columns)
       for i:= 0 to cxGrid1DBTableView1.DataController.ItemCount - 1 do
       begin
         if cxGrid1DBTableView1.Items[i].Visible then
         begin
           LFieldName:= TcxGridDBColumn(cxGrid1DBTableView1.Items[i]).DataBinding.FieldName;
           if ( trim( LFieldName ) <> '' ) and ( Dataset.FieldByName( LFieldName ).DataType = ftMemo ) then
           begin
             cxGrid1DBTableView1.Items[i].PropertiesClass:= TcxRichEditProperties;
             cxGrid1DBTableView1.Items[i].Options.IncSearch:= false;
             cxGrid1DBTableView1.Items[i].Options.Filtering:= false;
             cxGrid1DBTableView1.Items[i].Options.FilteringWithFindPanel:= false;
           end;
         end;
       end;
      end;

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.