Welcome to the Xceed Community | Help
Community Search  

dataviews in DataGrids

Sort Posts: Previous Next
  •  04-17-2008, 5:30 PM Post no. 11567

    dataviews in DataGrids

    My application is a GUI engine where the multiple UI screend are defined in XAML and Code Behind configuration file is used to map events and bindings to the controls. Before attempting to use your DataGid I was using ListViews tha were binded to dataviews that may be assocated with a data table or received data from the server. To populate the listview I created a dummy datatable with 20 columns and added the data items to each column as needed. This worked in the list view because it only showed the columns I had defined in the listview and mapped to the column in the dataview. The problem is I need a control that supports local user edits, grid lines and color control of a cell. I'm hoping your product will meet my requirements.

     

    Two questions 1 - I ran into the same problem as post 10931 with a hard error when moving focus from the insert row.when setting the DataGrid.ItemSource directly to the datavview. How in C# code do you assigned the dataview to the DataGridCollectionView and how in code do  you assign the DataGridCollectionView to a DataGrid control

     

    2 - It ther anyway to not show all the 20 columns in the dataview when I'm only populating 3 columns of data like the listview does now. I also do not want the user to see or be able to access the hidden columns 

  •  04-18-2008, 9:16 AM Post no. 11585 in reply to 11567

    Re: dataviews in DataGrids

    1-  you can do it this way:

    //if starting from a DataTable reference.
    myDataGridControl.ItemsSource = new DataGridCollectionView( myDataTable.DefaultView );

    //directly from a DataView
    myDataGridControl.ItemsSource = new DataGridCollectionView( myDataView );

    2- You can specify to the DataGridControl NOT to create its columns automatically based on the Data Source. This can be done by specifying myDataGridControl.AutoCreateColumns = false;

    From there, you can add columns manually to the DataGridControl.Columns collection.


    Marc Laroche
    Software Developer
    Xceed Software Inc.


    I don’t suffer from insanity, I enjoy every minute of it. - Unknown
  •  04-18-2008, 4:26 PM Post no. 11608 in reply to 11567

    Re: dataviews in DataGrids

    Thanks

    Two more questions please - I'm just a newbe

    1 If I set/leave alone AutoCreateColumns to true/default, have an InsertRow defined and set the columns I want visible things work the way I expect. I can edit the existing data and insert new data into the InsertRow. If I set the AutoCreateColumns to false and create the columns in the code the insert row is displayed but I can not entered any data. I can edit existing data.

    the code looks like this that works as expeacted

    //                m_lDataGridControl.AutoCreateColumns = false;

                       M_lDataGRidControl.Columns{"Text1"].Title = "TEST";

                        m_lDataGridControl.Columns["Text4"].Visible = false;

                                    .....

                         m_lDataGridControl.Colums{"Text20"].Visible = false;

     What does not work the way I expect is

                  m_lDataGridControl.AutoCreateColumns = false;

                   Column cColumn = new Column();

                   CColumn.Fieldname = "Text1";

                   cColumn.Title = "TEST";

                   m_lDataGridControl.Columns.Add(cColumn);

     /*                  m_lDataGRidControl.Columns{"Text1"].Title = "TEST";

                        m_lDataGridControl.Columns["Text4"].Visible = false;

                                    .....

                         m_lDataGridControl.Colums{"Text20"].Visible = false; */

     Second question is there a way that after you press the return key in the InsertRow and enter a new row that the cell in the InsertRow is in editmode instead of the user having to select the row. The idea is to create a seamless insert process where the user can enter data into a row, tab to each cell in the row enter data, press return and continue entering data on the new blank insertion row

       

     

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.