DataGridViewControl

dannidanni Denmark
edited February 2010 in FastReport .NET
Hi

I have a DialogForm with a DataGridViewControl on it. I set DataGridViewControl.Datasource to the band that contain the elements I want to show.

How do I show data from it? I cannot find any documentation on it.

The reason i have a grid is because I have a band with elements where i want to sho detailed information on one of the elements above the list of elements.


Below is a small idea of the report:

----------------------------------------------------------------------------------
band with no data:                      [txtName] [txtStartDate] [tstEndDate]
                                                 [txtAdress] [Country]

Databand DS.Elements                [DS.Elements.Name] [DS.Elements.Startdate] [DS.Elements.EndDate]

----------------------------------------------------------------------------------

The fields: txtName, txtStartDate, txtEndDate, txtAdress, Country are fields from the dialog form - or should be.

1. So basicly I wnat to show data form a selected row in the grid.
2. Know how to show data in the DataGridViewControl

Comments

  • edited 6:43AM
    Hello,

    You need to set the DataSource property, then set up columns. It can be done in the grid control's context menu, or in the Properties window (invoke the "Columns" property editor). To add all columns from datasource, press "Add all" button.
    I've attached a simple report that demonstrates how to print rows selected in a datagridview. You can run it in the demo.exe. Pay attention to the following:
    - OK button event handler (script)
    - data band filter
    1.frx 6.2K
  • dannidanni Denmark
    edited February 2010
    Hi,

    I set the datasource and get the columns by "get all". Still there is no data in the grid.

    If I just show the data in a band, data is shown fine. But data is not shown in the grid on the form.


    Here is a fragment of my datasource:
    DATA:
    PlanList (List<Plan>) 
    - Elements (List<Element>)
       - Structure (Object)
         - type  (String)
         - name (String)
    - PersonInfo  (Person object)
      - firstname (String)
      - lastname (String)
    


    When I loot at the field's column in the grid its
    Elements.Structure.type
    Elements.Structure.name.

    Sholdnt it be
    Planlist.Elements.Structure.type
    Planlist.Elements.Structure.name
    ?

    No matter what the grid dont show any data.
  • edited 6:43AM
    Hello,

    Grid cannot display data from business object source. Only TableDataSource is supported now.
  • dannidanni Denmark
    edited 6:43AM
    Ahh, okay. No wonder I cannot make it work then :-)

    Then I have few questions:
    1. Do you have a plan for implementing the ObjectdataSource for grids? When would that eg. be?
    2. Is ther antoher control where I can use objectdatasource and select 1 element? I do need a control that can show multible columns.
  • edited 6:43AM
    I will try to make it working in the next daily build (will be available tomorrow).
  • dannidanni Denmark
    edited 6:43AM
    That's fast I must say. I will take a look at it tomorrow then.

    Thank you :-)
  • dannidanni Denmark
    edited 6:43AM
    Hello again

    I downloaded version 1.3.51.0.

    From that I managed to get rows in the grid but no data shown.

    Do you know what could be the problem?

    I use standard settings for the columns.

    Here is a picture that shows the grid.
    tmp.jpg 38.1K
  • edited 6:43AM
    Hello,

    Could you send me a simple project that demonstrates the error? I've tried to use the Grid control in the "Business Objects" demo report, it works well.
  • dannidanni Denmark
    edited 6:43AM
    I must do something wrong.

    If I use the BusinessObjects I get no data either.
  • edited 6:43AM
    Hello,

    There may be the problem if you display data from nested BO. You need to manually adjust the "DataColumn" property of each grid column (in the grid columns editor). Use full name of the data column, including its parent BO name, for example: replace "Products.Name" with "Categories BusinessObject.Products.Name".
  • dannidanni Denmark
    edited 6:43AM
    That did the trick.

    I will set the columns manually.

    Thank you :-)
  • dannidanni Denmark
    edited 6:43AM
    Hi again

    Not all columns in the grid show data when using Businessobjects.

    It seems only the first level of the object tree is shown in the grid.

    From the structure below the cells will not get values for Street and Number. Because its in the second level of the object tree.
    Some List
      - Name (Property:String)
      - Address (Property:AdressObject)
           -  Street (Property:String)
           -  Number (Property:String)
    
  • edited 6:43AM
    It's a limitation of the DataGridView wincontrol. It does not support binding to nested properties.
  • dannidanni Denmark
    edited 6:43AM
    Hi again.

    Isn't that a problem when it is possible to choose columns in nested objects?

  • edited 6:43AM
    It is possible to choose any column, but only top-level columns may be displayed in a grid control.
  • dannidanni Denmark
    edited 6:43AM
    Hi again

    It dosnt seem logic that it is possible to choose columns in nested objects when they cannot be displayed.

    Some grids support nested objects. We use a grid from Telerik and DevExpress in my company.

    Would it be possible to get that feature somehow?


    Secondly: Does this functionality behave similar if I use a DataSet as datasource to the report insted?
  • edited 6:43AM
    We have no plans to support Telerik / Devexpress grids, but you may do it by yourself. Dialog controls architecture is extendable. If you interested I will prepare a short guide for you.
    Grid will work with DataSet, just like the standard winforms DataGridView control.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.