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
I had two issues. First, the Key for my second and should have been the name of the relation (FM_TASK) and the second problem is that I had a column in my design that was not in my table. I just figured that it would just disreguard it and move on. I guess not.
Mark <><
While I completely agree with you, I'm not sure what to change it to? As you can see from my code, I have two tables in a parent/child relationship. The parrent table is identified as "FM", the child table is refered to as "Task". Those are the exact names that I have set as the Key property in the designer. My guess is that I need to refer to my second table as something other than "Task". So, based on the following dataset, what should I set the Key property for my bands?
Dim daFM As OleDbDataAdapter = New OleDbDataAdapter(lSQL_FM, con) Dim dsFM As DataSet = New DataSet daFM.Fill(dsFM, "FM") Dim daTask As OleDbDataAdapter = New OleDbDataAdapter(lSQL_TASK, con) daTask.Fill(dsFM, "Task") dsFM.Relations.Add("FM_TASK", dsFM.Tables("FM").Columns("ID"), dsFM.Tables("Task").Columns("FM_ID")) PackageGrid.SetDataBinding(dsFM.Tables("FM"), Nothing, True)
I've added a shot of my designer to show the values of the first and second band. Also, I've tried the RowLayout approach but right now I'm trying to figure out how to apply a layout at runtime.
Hi Mark,
It sounds to me like something is not matching up. Either the column names, band names, or column data types on the child band must be different between run-time and design-time. My guess is the band name, that's the most common mistake people make when setting up the grid at design-time.
You might want to check the Key of each band in the grid at run-time to make sure you are using the correct band keys in your design-time layout.
Dim daFM As OleDbDataAdapter = New OleDbDataAdapter(lSQL_FM, con)Dim dsFM As DataSet = New DataSetdaFM.Fill(dsFM, "FM")Dim daTask As OleDbDataAdapter = New OleDbDataAdapter(lSQL_TASK, con)daTask.Fill(dsFM, "Task")dsFM.Relations.Add("FM_TASK", dsFM.Tables("FM").Columns("ID"), dsFM.Tables("Task").Columns("FM_ID"))PackageGrid.SetDataBinding(dsFM.Tables("FM"), Nothing, True)
The grid will display two bands as expected and will even bind the columns to the first band. For example, if I change the column caption in the designer for one of the data columns in the first band [Bands(0)] the change is reflected in the runtime grid. The problem I'm having now is that any design changes I make to the second band [Bands(1)] are not reflected in the runtime grid.
Thanks for the assistance.
P.S. I've also posted this question in the Help Center hoping to get an answer as complete and quick as possible.
Mark Flach <><
Actually, my grid will be far more complex than the example I provided. My intent was to give a basic idea of what I'm doing. My actual grid will have two bands with the first band having 1 level and the second band having 3 levels.
lSQL = "SHAPE{" & lSQL_FM & "}" & _" APPEND ({ " & lSQL_TASK & "} as fmecaTASK RELATE 'ID' to 'FM_ID') as fmecaFM "
Dim rs As New ADODB.RecordsetDim da As OleDbDataAdapter = New OleDbDataAdapter(lSQL, con)Dim ds As DataSet = New DataSetda.Fill(ds)Dim dt As DataTabledt = ds.Tables("Table")PackageGrid.SetDataBinding(dt, Nothing, True)
I would really like to design my grid at design time and just set the datasource and call it a day. I've also tried to add the following code to no avail.
e.Layout.Bands(1).LevelCount = 2e.Layout.Bands(1).Columns("LOM").Level = 1
Any thoughts?