Home Forums WPF controls Xceed DataGrid for WPF Creating a column in code-behind

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • Xceed Support
    Member
    Post count: 5658
    #21632 |

    Hi,

    I’m trying to create a dynamique grid, the columns are created at runtime.
    I have 3 problems:

    1- I have an InsertionRow, but I can’t write any values in the different columns.

    2- When I click on a column header, the sort is not applyed.

    3- Some of my properties in the binding object are read only, when I double click on a cell that is read only, I have the following message: An attempt was made to edit a readonly cell.
    How can I prevent that message?

    I’m using a BindingSource for the grid ItemSource, is that the cause of my problem?

    Thanks in advance.

    Imported from legacy forums. Posted by Simon (had 7068 views)

    Xceed Support
    Member
    Post count: 5658

    Can you provide the code you use to create the columns?

    Also, if you could provide the code used to create and configure your data source.

    Thanks

    Imported from legacy forums. Posted by Marcus [Xceed] (had 367 views)

    Xceed Support
    Member
    Post count: 5658

    Hi,
    This is the function to create column:

    public Column CreateColumn( PropertyInfo aPropertyInfo )
    {
    ListColumnInfoAttribute listColumnInfoAttribute = TypeHelper.GetSingleCustomAtributes<ListColumnInfoAttribute>( aPropertyInfo, true, true );
    EditableColumnAttribute editableColumnAttribute = TypeHelper.GetSingleCustomAtributes<EditableColumnAttribute>( aPropertyInfo, true, true );
    ListColumnValueListAttribute listColumnValueListAttribute = TypeHelper.GetSingleCustomAtributes<ListColumnValueListAttribute>( aPropertyInfo, true, true );

    Column column = new Column( aPropertyInfo.Name, listColumnInfoAttribute.ColumnName, new Binding( aPropertyInfo.Name ) );
    column.TextWrapping = TextWrapping.Wrap;

    if ( listColumnInfoAttribute.ColumnWidth != 0 )
    {
    column.Width = listColumnInfoAttribute.ColumnWidth;
    }
    return column;
    }

    This is the Binding Source:

    public partial class MNIBindingSource : AbstractDataBindingSource
    {
    public MNIBindingSource()
    {
    }

    public override List<Type> EntityTypes
    {
    get
    {
    List<Type> typeList = new List<Type>();
    typeList.Add( typeof( MNIEntity ) );
    return typeList;
    }
    }

    public override Type DataBindingObjectType
    {
    get
    {
    return typeof( MNIBindingObject );
    }
    }

    public override AbstractDataBindingSource Clone()
    {
    MNIBindingSource bindingSource = new MNIBindingSource();
    return bindingSource;
    }
    }

    and its in the binding object that all the properties are.
    If you need anything else to help me, just say so.

    Thanks in advance.

    Imported from legacy forums. Posted by Simon (had 379 views)

    Xceed Support
    Member
    Post count: 5658

    #1:

    When creating a column manually, a CellEditor is not provided by default on the Column (which is the reason why you can’t edit the cells of the InsertionRow).

    You need to add explicitelly the CellEditor to the created row… You can find some basic editors in the CellEditor static members… But you’ll otherwise need to create your own editor.

    #2:

    Can you verify the return value of your BindingSource.SupportsSorting? My assumption is that your BindingSource returns false (making the data grid not-sortable), can you confirm this?

    #3:

    That is definitely a bug… I have filed a bug report, and we will address that as soon as possible.

    In the mean time, you can workaround this bug by removing the “ClickOnCurrentCell” from the EditTriggers of the datagrid control. (ActivationGesture is also at risk)

    Imported from legacy forums. Posted by Marcus [Xceed] (had 529 views)

    Xceed Support
    Member
    Post count: 5658

    Hi,

    #1 Works great thanks.

    #2 You were right, it does return false.

    #3 Works great thanks.

    Other Problem, I can seem to catch the event AddingNewDataItem.
    When is it fired? Is it because I work with a BindingSource?

    When adding a new item, I can see that it was added to the BindingSource, but non of the value that I have entered are there. Is this another bug?

    I have a sample app if you want to see what the problems I have.

    PS: I wounder why we write each other in english, you are in Longueuil and I’m in Laval. Funny!

    Imported from legacy forums. Posted by Simon (had 377 views)

    Xceed Support
    Member
    Post count: 5658

    The AddingNewDataItem event is only triggered when the datagrid control is unbound (no ItemsSource). This event is used to allow user of an unbound datagrid to create the desired data object.

    If you want to initialize the content of the InsertionRow’s cell to a particular value, then you can use the InitializingInsertionRow event, which is triggered whenever the InsertionRow enters edition.

    As for the problem concerning the blank cells, I’d like to see this case in more details, if you can share the sample application you refer to, that would help me a lot…

    Let me know if you cannot publicly share an URL to this code, and I’ll arrange a way for you to send me your files.

    PS: Since most of the community share English as a common language, its the best choice for us since we want the content of this forum to be as reusable as possible for other community members. So please do not take it personal if I continue using English on the forum while addressing you.

    PPS: Le monde est effectivement petit, je suis bien content de voir qu’une compagnie Québécoise utilise notre grille.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 712 views)

    Xceed Support
    Member
    Post count: 5658

    I cannot publicly share an URL to this code, do I send a email to support@xceedsoft.com with Marcus has subject?

    Thanks for your help.

    Imported from legacy forums. Posted by Simon (had 329 views)

    Xceed Support
    Member
    Post count: 5658

    Exceptionally yes, send an email to the support with my nick in the topic… I asked tech support to route it to me…

    Thanks

    Imported from legacy forums. Posted by Marcus [Xceed] (had 480 views)

    Xceed Support
    Member
    Post count: 5658

    The problem you are encountering relates to the fact that when you create your columns, since you don`t affect explicitly the Mode, the Mode defaults to “OneWay”. This prevents the data object from being updated with the values entered in the InsertionRow.

    We are already working on an improvement which will prevent edition of a cell if the column`s binding is not “TwoWay”, making much easier the detection of such cases.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 598 views)

    User (Old forums)
    Member
    Post count: 23064

    #3: This bug has been fixed in the latest release (Package v3.0.7113.09060, DatGrid assemblies v1.0.7113.3050), which has just been posted here:

    http://download3.xceedsoft.com/Packages/3.0.7113.09060/XceedComponents.exe

    The website has not yet been updated (release notes, update center, etc), but it will be soon.

    Imported from legacy forums. Posted by Pascal (had 8159 views)

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.