User (Old forums)MemberNovember 28, 2007 at 12:47 pmPost count: 23064
Hi, I’m new to Xceed grids, still coming up from VS Flexgrid (pre .NET) from several years ago.
I am trying to insert a row with a checkbox in column 1, text in column two, and text in column 3.
So far, I can insert a row, but I am still trying to figure out how to put content into that row. Any help would be appreciated.
ItemCollection items = gridDefaultEdit.Items;
DataRow row = new DataRow();
DataCell cell = new DataCell();
cell = new DataCell();
cell.Content = new CheckBox();
When I execute the above, my row doesn’t appear to have a checkbox in it. I’m not even sure how to set the text in each cell yet. The XAML for my grid has several columns with headers already defined. I can post that if anyone is interested.
Imported from legacy forums. Posted by Eric (had 5063 views)User (Old forums)MemberNovember 28, 2007 at 1:56 pmPost count: 23064
Easier to add it through adding the underlying data into the collection. The grid will update automatically.
Imported from legacy forums. Posted by nat (had 516 views)User (Old forums)MemberNovember 28, 2007 at 2:15 pmPost count: 23064
I’m so new to this, I’m not sure what you mean by that. Am I not already adding it through the underlying data? Could you possibly elaborate?
Imported from legacy forums. Posted by Eric (had 467 views)Xceed SupportMemberNovember 28, 2007 at 4:22 pmPost count: 5658
There is no need for you to create a datarow and add it to the items collection; you can simply pass your object instance to the collection and a DataRow will be created for it. How the content of a cell is displayed (by default) depends on the data type of the corresponding cell. For example, when an instance of an object that contains a boolean property is added to the items collection, it will be displayed as a checkbox.
If you are still having issues, I suggest you take a look at the Object Model Overview in the documentation as well as the Providing Data topics.
Imported from legacy forums. Posted by Jenny [Xceed] (had 267 views)User (Old forums)MemberNovember 28, 2007 at 5:20 pmPost count: 23064
What if the row that I wish to display is a mix of both a checkbox plus the class I would like to display? Are you saying that to do this in the Xceed datagrid, I need to create a class which takes both a checkbox and the class that I want to display?
Imported from legacy forums. Posted by Eric (had 418 views)Xceed SupportMemberNovember 28, 2007 at 7:01 pmPost count: 5658
I am not sure I understand so I will give you an example and you can tell me if this is similar to what you want to do:
Say you have a Person class that defines 3 properties: FirstName, LastName, and Adult. The first 2 are strings, while the third is a boolean. If I create three instances of this class, each time providing a first name, a last name, and a boolean value indicating if the person is an adult, and add each instance to the Items collection, I would expect the grid to display 3 columns with 3 rows, that display the information. For example:
FirstName | LastName | Adult
Jenny | Beland | Yes
Medicine | Man | Yes
Someone | Else | No
However, since by default the grid will display a boolean value as a checkbox, both “yes”s will appear as checked checkboxes while the “no” will appear as an unchecked checkbox.
Is this similar to what you would like to do? If not, can you provide a screenshot of what you would like?
Imported from legacy forums. Posted by Jenny [Xceed] (had 492 views)User (Old forums)MemberDecember 5, 2007 at 7:24 pmPost count: 23064
Yes, this is very similar to what I would like to do. However, in our case, the checkbox is a selector for different actions:
1. Display the collection of Person class
2. Select rows of interest by checking a checkbox which appears in the first column of each row. 3. Press button on form to execute action on selected rows of interest.
As a result, I would prefer the class to not have this boolean field.
Imported from legacy forums. Posted by Eric (had 418 views)Xceed SupportMemberDecember 6, 2007 at 9:32 amPost count: 5658
Ok. In this case, since the grid does not support unbound columns, you will not be able to have the selection column in the grid. That said, you can either have the checkboxes outside the grid, or you could change the ContentTemplate of the RowSelector to display a checkbox and use the RowSelector’s ItemIndex property to add or remove the row at the selected index in the grid’s SelectedItems collection.
Imported from legacy forums. Posted by Jenny [Xceed] (had 6615 views)
- You must be logged in to reply to this topic.