0
votes

I have a normal data binding situation where my underlying question object properties are bound to columns in a devexpress XtraGrid.GridControl. However, I have one text property that takes the form of "{Question|True},{Question|False}". These must be mapped to checkboxes in the grid (potentially many per property). Is it possible to use data binding to bind this string property directly to a cell, providing checkbox editing, perhaps using a CheckedComboBox? I'm thinking I'd need an intermediate step in the binding process to map the original string to checkboxes, and then from the checkboxes back to the string.

Otherwise my current thinking is to create another layer of objects, which contains a new object for each of the checkbox options, but if I could somehow interrupt the default binding process with a mapping from the above text to the checkboxes in a CheckComboBox I'd be able to bind straight to the underlying objects.

2
DX grid is very flexible in terms of binding. So I'm sure it should be possible to achieve what you want. But first pls provide a screenshot of UI sketch of how you want those checkboxes to look like in the grid row/cell. - andrews

2 Answers

0
votes

If I understood you well I think that you should change your question object to contain bool property. Bool properties are bound to grid as checkboxes, so it will work automatically. I know that your real value of that property should be string "{Question|True}" so you can set that property in that way:

    private string question;

private bool questionBool;
public bool QuestionBool{
get{return questionBool;}
set{
if(value) 
   question = "{Question|True}"};
else
   question = "{Question|False}";

questionBool = value;

}
0
votes

I ended up converting the text into a collection of CheckboxQuestionAndAnswer objects which I then bound to the grid, then converting them back into a single text string for writing the data back.