Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
835
Add level at runtime
posted

 I have a WinGrid that needs to display a large number of columns.  I'm binding to a datasourse at runtime so I can't design my layout at design time.  How do I display my data on multiple lines (Levels).  I was under the impression that there is no way to bind my data at runtime and still use the structure created at desing time.  If that is true, I need to produce my structure at runtime.

  Something like this:

 

 

Description

Name

Type

Code

Cost

Approved

Description 1

Bob

M

01

$12.00

Yes

Description 2

Mary

F

02

$14.25

No

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

     You can set up your layout at design-time and use it at run-time. Here's a KB article that shows you how. 

     HOWTO:How can I define columns in the grid at Design-time and bind them at run-time so that some fields of the data are excluded from the grid?

    The layout you have here is pretty simple, though, and you could probably do this more easily using Groups and Levels. Use the InitializeLayout event of the grid. Add one or more Groups to the band (band.Groups.Add). Then you have to assign each column to a group. In this case, you probably only need one group - Description. Then you can set LevelCount on on the band to 2 so each row is two levels and also set the Level property on each column.

    There is still another way to do this, too. Since it looks like you just need everything on one line except one field (Description), then you could probably just use the RowAutoPreview functionality. The auto preview is not editable, though, so this method won't work if you need the description field to be editable by the user. 

Children