Can anyone write me a code where I can create a hierarchical grid programmatically by adding each row separately? I know data binding is a nice cute feature but our software design doesn't permit us using the binding directly. So I need to add data one by one in the grid, that too in hierarchical fashion.
The concept of bands is kinda confusing.
Can anyone please just write a small like of code where I create a grid, add couple of columns and a couple of rows to it. And for each row I need to two columns and 1 row each.
Thanks. I just need an idea of the thing.
Super Stuff. Thanks :)
neebz said:Is there any function where I can get all the rows which have checked check boxes? Or do I have to go through each of check boxes one by one and then find out which were checked
To the best of my knowledge, you need to loop through the grid and check each row. Here's how I've done it:
Dim lResult As New Collection Dim lCheckCell As UltraGridCell Dim lValueCell As UltraGridCell
If lRow.HasChildRows Then 'Only scan lowest band - recursively RowsCollectionCheckedValuesCollect(lRow.Rows, vCheckboxColumnPosition, vValueColumnPosition, rValues) Else lCheckCell = lRow.Cells(vCheckboxColumnPosition) If CBool(lCheckCell.Value) Then lValueCell = lRow.Cells(vValueColumnPosition) rValues.Add(CInt(lValueCell.Value)) End If End If
Next
End Sub
One last thing,
Now that I've created all the grid and added the checkboxes. Is there any function where I can get all the rows which have checked check boxes? Or do I have to go through each of check boxes one by one and then find out which were checked and which one were there corresponding rows and so on?
neebz said:can anyone tell me how to add another column in each row containing a simple checkbox ?
Create it like any other column, then set its .Type to CheckBox. Then you use the .Value property to check get or set what you'd think of as the checkbox's .checked property.
Hmm. Thanx a lot. I find no issues with the above apart from the extra over head of creating a data set row by row and then binding it rather than simply adding the rows directly.
Though through trail and error I have been able to create it. Following is the code for that (firstEverGrid is a grid already declared at design time)
UltraGridBand firstBand = new UltraGridBand(true);
firstBand.Columns.Add("column2", "doosra column");
secondBand.Columns.Add("column3", "teesra column");
firstEverGrid.Bands.Add(firstBand);
UltraGridCell cell3 = new UltraGridCell("hello baby3");
UltraGridCell cell5 = new UltraGridCell("hello baby5");
UltraGridCell cell7 = new UltraGridCell("hello baby7");
Row1.Cells.Add(cell1);
Row1.Cells.Add(cell2);
Row2.Cells.Add(cell3);
Row2.Cells.Add(cell4);
Row3.Cells.Add(cell5);
Row3.Cells.Add(cell6);
Row4.Cells.Add(cell7);
Row4.Cells.Add(cell8);
Row1.Rows.Add(Row3);
Row2.Rows.Add(Row4);
firstEverGrid.Rows.Add(Row1);
firstEverGrid.Rows.Add(Row2);
----
This create twos rows each containing one row inside.
Now can anyone tell me how to add another column in each row containing a simple checkbox ?
Thanx