Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Please help

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

Please help
Link Posted: 27-Oct-2005 22:01
Hello,

On my form I have a FlyGrid connected to a dataset. It shows only one row and one column with correct value.

Above I have a tab control, which tabpage is a user control with a flygrid inside (the exact same one as the one on the form). And yet instead of showing the same row as in the other grid, it shows 'System.Data.DataRowView'. I don't understand why, as I'm doing exactely the same thing as on the form.

Could you have a look at the code please? Just change the stored procedure called in GetReportFields by one of your own.
The code is here: http://graphicsxp.free.fr/tab.zip

Thank you

EDIT

I SHOULD MENTION THAT IT WORKS FINE IF I USE A MICROSOFT GRID INSTEAD
Link Posted: 28-Oct-2005 00:32
I've looked at your code,
are sure that in the PrepareColumn() you're using right filed name? And that column with this field name exists in the connected data source?


Public Sub PrepareColumn()
  FlyGrid1.BeginInit()
  FlyGrid1.Columns.Items.Clear()
  Dim FieldName As New Column("Field Name", "FieldName") '<<<<---------
  FieldName.FitMode = ColumnFitMode.SmartFit
  FlyGrid1.Columns.Items.Add(FieldName)
  FlyGrid1.EndInit()
End Sub


Unfortunately I can't see the contents and structure of connected database as your demo uses SQLServer.
Link Posted: 28-Oct-2005 00:43
Yes I am 100% sure. Don't you have SQL Server to test with a stored procedure of your own?
The top grid and bottom grid have the same PrepareColumn function and same datasource, bottom grid which is not in user control shows correct data. but top grid in user control does not.
Link Posted: 28-Oct-2005 01:06
I've SQL Server running but receive "System.Data.SQLException" (System Error) at the tab.Global.main procedure.
But I've not found in your code any additions of DataColumn with field name  = "FieldName" , I've found (Database.vb, sub CreateEmptyTable) that you've added "Id" and "New" columns.
Link Posted: 28-Oct-2005 01:14
CreateEmptyTable ? But this function is not even called in UserControl1.vb.

The datasource of my grid is filled using this function :


Public Function GetReportFields(ByVal ReportTabId As Integer) As DataSet
        Dim da As New DatabaseAccess
        Try
            da.AddTable("pr_Admin_GetReportFields", DatabaseAccess.SQLType.StoredProcedure)
            da.Commands(0).Parameters.Add("@ReportTabId", ReportTabId)

            da.AddTable("pr_Admin_GetFieldTypes", DatabaseAccess.SQLType.StoredProcedure)

            Return da.GetDataset
        Catch ex As Exception
            MsgBox(ex.ToString, MsgBoxStyle.Exclamation, "Warning")
        End Try
    End Function


Also, in the global module, you need to change the connection string so it matches your configuration
Link Posted: 28-Oct-2005 01:22
In this case, could you populate field names of connected table into debug:

for(int i=0; i < dataTable.Columns.Count; i++)
{
   DataColumn dc = dataTable.Columns[i];
  System.Diagnostics.Debug.WriteLine(string.Fromat("Col {0} :FieldName {0}", dataTable.Columns[i].ColumnName));
}

to recognize field names.

Also try to to move PrepareColumn() procedure to place before flyGrid.Rows.DataSource Initialization.
Link Posted: 28-Oct-2005 01:30
Output is:

Col ReportFieldId :FieldName ReportFieldId
Col WebId :FieldName WebId
Col FieldName :FieldName FieldName
Col FieldTypeId :FieldName FieldTypeId
Col ViewTable :FieldName ViewTable
Col ViewField :FieldName ViewField
Col SortOrder :FieldName SortOrder
Col ReportTabId :FieldName ReportTabId


so FieldName is a valid fieldname

I've moved PrepareColumn before
FlyGrid1.Rows.DataMember = m_dsFields.Tables(0).TableName
FlyGrid1.Rows.DataSource = m_dsFields

But still same problem
Link Posted: 28-Oct-2005 01:47
Another suggestion:
try to add column to flyGrid with fieldname from FieldName column:
flyGrid.Columns.Items.Add(new Column(dataColumn.ColumnName, dataColumn.ColumnName)).
Also you can try to use your column type inherited from Column for testing purposes.
Link Posted: 28-Oct-2005 01:52
try to add column to flyGrid with fieldname from FieldName
column:


my new preparecolumn:

Public Sub PrepareColumn()
        FlyGrid1.BeginInit()
        FlyGrid1.Columns.Items.Clear()

        For Each col As DataColumn In m_dsFields.Tables(0).Columns
            If col.ColumnName = "FieldName" Then
                FlyGrid1.Columns.Items.Add(New Column(col.ColumnName, col.ColumnName))
            End If
        Next
        FlyGrid1.EndInit()
    End Sub


Same problem.....


Also you can try to use your column type inherited from Column for testing purposes.

What do you mean ?
Link Posted: 28-Oct-2005 01:58
If I create my datatable in code:


        Dim dt As New DataTable
        Dim col As New DataColumn("FieldName")
        col.DataType = GetType(String)
        dt.Columns.Add(col)

        Dim row As DataRow = dt.NewRow
        row("FieldName") = "test"
        dt.Rows.Add(row)


it works fine.

And yet, I can assure you that FieldName is a correct column name in the datatable filled from stored procedure and datatable contains correct data, and that it works fine if the grid is put on the form and not in user control.
proof:

?m_dsfields.Tables(0).Columns(2).ColumnName
"FieldName"


?m_dsfields.Tables(0).Rows(0).Item(2)
"det1" {String}
    String: "det1"

Any suggestions ?