Home - Forums-.NET - FlyGrid.Net (Windows Forms) - issue with dataview and combobox column

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

issue with dataview and combobox column
Link Posted: 02-Sep-2005 01:24
Hi,
The following code works fine with Flygrid 1.0 but doesn't with 1.2 :

dvCtrlFields = m_fields.GetCtrlSrcFields(dt, _
                            Convert.ToInt32(dt.Rows(m_SelectedControl).Item("FieldID")))

                'Set up m_ControlField
                m_ControlField = DirectCast(dgParams.Columns.Items(EParamFields.e_controlField), LookupListColumn)
                m_ControlField.LookupSource = dvCtrlFields
                m_ControlField.LookupDataMember = dvCtrlFields.Table.TableName
                m_ControlField.LookupBoundField = "FieldID"
                m_ControlField.LookupDisplayField = "FieldName"
                dgParams.Columns.Items(EParamFields.e_controlField) = m_ControlField


Can't we have a dataview as datasource for a grid anymore ?

Kind Regards
Link Posted: 04-Sep-2005 11:56
Please download latest FlyGrid update (1.2.1), this incorrectness is fixed.
Link Posted: 04-Sep-2005 21:49
I can't see any difference with the new version. This code still works fine with 1.0 but not with versions from 1.2. I'm not sure it comes from the dataview actually. Here is a description of what I do:

In prepare column :

    
   m_ControlField = New LookupListColumn("Control", "ControlField")
        m_ControlField.FitMode = ColumnFitMode.SmartFit
        m_ControlField.DropDownStyle = DropDownStyle.DropDownList
        m_ControlField.LookupSource = dtEmp
        m_ControlField.LookupBoundField = "Id"
        m_ControlField.LookupDisplayField = "New"
        dgParams.Columns.Items.Add(m_ControlField)


Then, based on other operations and processing, I change the source of m_ControlField :

dvCtrlFields = m_fields.GetCtrlSrcFields(dt, _
                            Convert.ToInt32(dt.Rows(m_SelectedControl).Item("FieldID")))

            
    'Set up m_ControlField
                m_ControlField = DirectCast(dgParams.Columns.Items(EParamFields.e_controlField), LookupListColumn)
                m_ControlField.LookupSource = dvCtrlFields
                m_ControlField.LookupDataMember = dvCtrlFields.Table.TableName
                m_ControlField.LookupBoundField = "FieldID"
                m_ControlField.LookupDisplayField = "FieldName"
                dgParams.Columns.Items(EParamFields.e_controlField) = m_ControlField


RESULT : I can't select any values in the combo, as if it was read-only and when I double click on it I've got the exception :

       Value cannot be null.

On top of that, existing records show the FieldID instead of showing the FieldName as indicated in LookupDisplayField !

Again, all works fine with 1.0, please have a look at this asap.

Regards
Link Posted: 05-Sep-2005 06:48
If dvCtrlFields is DataView, your following code probably is incorrect:
'Set up m_ControlField
m_ControlField = DirectCast(dgParams.Columns.Items(EParamFields.e_controlField), LookupListColumn)
m_ControlField.LookupSource = dvCtrlFields 'DataView???
m_ControlField.LookupDataMember = dvCtrlFields.Table.TableName
m_ControlField.LookupBoundField = "FieldID"
m_ControlField.LookupDisplayField = "FieldName"
dgParams.Columns.Items(EParamFields.e_controlField) = m_ControlField


If you use DataTable/DataView as LookupSource, do not use  LookupDataMember if you DataTable/DataView doesn't contains child list or records.
More correctly:
'Set up m_ControlField
m_ControlField = DirectCast(dgParams.Columns.Items(EParamFields.e_controlField), LookupListColumn)
m_ControlField.LookupSource = dvCtrlFields
m_ControlField.LookupBoundField = "FieldID"
m_ControlField.LookupDisplayField = "FieldName"
dgParams.Columns.Items(EParamFields.e_controlField) = m_ControlField
Link Posted: 05-Sep-2005 07:08
Thank you for your reply. However that doesn't fix the bug. Moreover, as I said already, if it works with 1.0 and not with 1.2, I'd be very surprised the issue is in my code. Could you help further please ?

Regards
Link Posted: 05-Sep-2005 09:49
My code is too big and right now I don't have time to create a sample. If the problem comes from my code then how come it works with 1.0 (I've just tested again, fine) ? What has changed between 1.0 and 1.2 ? Why would I need to modify the code ?
Link Posted: 05-Sep-2005 09:50
Problem in your code,  we've tested LookupListcolumn on different datasources (DataTable, DataView, DataSet) - all works fine,
could you send me a smaple that shows this incorrection to quickly fix.
Link Posted: 05-Sep-2005 22:57
I can't send you a sample but here is a more accurate description of what I'm doing:

      
  m_ControlField = New LookupListColumn("Control", "ControlField")  -->  ControlField is a NULL field
        m_ControlField.FitMode = ColumnFitMode.SmartFit
        m_ControlField.DropDownStyle = DropDownStyle.DropDownList
        m_ControlField.LookupSource = dtEmp
        m_ControlField.LookupBoundField = "Id"
        m_ControlField.LookupDisplayField = "New"
        dgParams.Columns.Items.Add(m_ControlField)


above, dtEmp is an empty datatable:

          
dt.Columns.Add("Id", GetType(System.Int32))
            dt.Columns.Add("New", GetType(System.String))
            row = dt.NewRow()
            row(0) = DBNull.Value
            row(1) = DBNull.Value
            rc = dt.Rows
            rc.InsertAt(row, 0)


Then, when I select a row in another grid, the m_ControlField column is updated accordingly in dgParams, by changing its datasource to a dataview:

       dvCtrlFields = m_fields.GetCtrlSrcFields(dt, _
                            Convert.ToInt32(dt.Rows(m_SelectedControl).Item("FieldID")))

                'Set up m_ControlField
                m_ControlField = DirectCast(dgParams.Columns.Items(EParamFields.e_controlField), LookupListColumn)
                m_ControlField.LookupSource = dvCtrlFields
                m_ControlField.LookupBoundField = "FieldID"
                m_ControlField.LookupDisplayField = "FieldName"
                dgParams.Columns.Items(EParamFields.e_controlField) =  m_ControlField


Unfortunately, with version 1.2 of the flygrid this doesn't work. m_ControlField remains empty, I can't select a value as if it was read-only and finally if I double click on the combobox I have the message:

Value cannot be null.

Please help me with this issue.
Link Posted: 06-Sep-2005 21:55
Problem was not in my code.
Fixed at last with the latest build !

Thank you.