Problem with DataGridView and BindingSource

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shibeta@wp.pl

    Problem with DataGridView and BindingSource

    Hello,
    I have problem with DataGridView and BindingSource. I have created
    DataSet and added TableData to it with manualy created columns
    (without DataAdapter - I'm not using MSSQL). On the Form I put
    DataGridView and BindingSource, and connected them (BindingSource of
    course is also connected with DataSet). Next on the separated thread
    I'm reading data from DB and load them do DataSet (more preciselly,
    readed data I've saved as XML and them this XML load to DataSet).
    Everything looks OK - DataSet is filled with rows :D But nothing
    appears on the DataGridView, so on the end of thread I've executed
    "refreshBS( )" method (like below - threadsafe) and the datgridview
    fills with rows, too.

    public void refreshBS()
    {
    if (this.InvokeReq uired)
    {
    RefreshUserDeta ils rud = new
    RefreshUserDeta ils(this.refres hBS);
    this.Invoke(rud );
    }
    else
    {
    this.DataSet1.A cceptChanges();
    this.BindingSou rce.CurrencyMan ager.Refresh();
    }
    }

    I thought that everything is OK until I've lunch my application
    from .EXE file :-( I have discovered that when I lunch it from .EXE
    file it hangs on the line give above
    "this.BindingSo urce.CurrencyMa nager.Refresh() " (when I lunch this from
    Visual Studio (F5) everything works fine).
    My question is : is there any other way to refresh DataGridView with
    data from BindingSource ?
    Also i have tested the method :
    CurrencyManager cm = this.Datagridvi ew.bindingconte xt.....
    cm.refresh()
    and the result is the same :-(

    Now to refresh data on DataGridView with BindingSource I'm sorting
    DataGridView programatically and it helps but I think that it's not
    the way it should be done.
    Thanks.

  • RobinS

    #2
    Re: Problem with DataGridView and BindingSource

    Are you loading your dataset before you set the data source of the
    bindingsource to the dataset?

    Robin S.
    -----------------------------------------
    <shibeta@wp.plw rote in message
    news:1170259360 .884127.102780@ q2g2000cwa.goog legroups.com...
    Hello,
    I have problem with DataGridView and BindingSource. I have created
    DataSet and added TableData to it with manualy created columns
    (without DataAdapter - I'm not using MSSQL). On the Form I put
    DataGridView and BindingSource, and connected them (BindingSource of
    course is also connected with DataSet). Next on the separated thread
    I'm reading data from DB and load them do DataSet (more preciselly,
    readed data I've saved as XML and them this XML load to DataSet).
    Everything looks OK - DataSet is filled with rows :D But nothing
    appears on the DataGridView, so on the end of thread I've executed
    "refreshBS( )" method (like below - threadsafe) and the datgridview
    fills with rows, too.
    >
    public void refreshBS()
    {
    if (this.InvokeReq uired)
    {
    RefreshUserDeta ils rud = new
    RefreshUserDeta ils(this.refres hBS);
    this.Invoke(rud );
    }
    else
    {
    this.DataSet1.A cceptChanges();
    this.BindingSou rce.CurrencyMan ager.Refresh();
    }
    }
    >
    I thought that everything is OK until I've lunch my application
    from .EXE file :-( I have discovered that when I lunch it from .EXE
    file it hangs on the line give above
    "this.BindingSo urce.CurrencyMa nager.Refresh() " (when I lunch this from
    Visual Studio (F5) everything works fine).
    My question is : is there any other way to refresh DataGridView with
    data from BindingSource ?
    Also i have tested the method :
    CurrencyManager cm = this.Datagridvi ew.bindingconte xt.....
    cm.refresh()
    and the result is the same :-(
    >
    Now to refresh data on DataGridView with BindingSource I'm sorting
    DataGridView programatically and it helps but I think that it's not
    the way it should be done.
    Thanks.
    >

    Comment

    • shibeta@wp.pl

      #3
      Re: Problem with DataGridView and BindingSource

      On 1 Lut, 10:49, "RobinS" <Rob...@NoSpam. yah.nonewrote:
      Are you loading your dataset before you set the data source of the
      bindingsource to the dataset?
      >
      Robin S.
      No. All connections between DataSet, BindingSource and DataGridView
      are done at the design level, from the Visual Studio. DataSet is
      filling with data after launching the application (thread). It's
      needed because I want to format columns in DataGridView at the design
      level.

      Comment

      • shibeta@wp.pl

        #4
        Re: Problem with DataGridView and BindingSource

        Also I want to mention that this problem occurs only if there will be
        more rows than DataGridView can show at one time. For example if
        DataGridView can fit only 10 rows (on the screen) and I want to show
        12 rows the application will hang, but if I want to show only 8 rows
        then everything will be OK.


        Comment

        • shibeta@wp.pl

          #5
          Re: Problem with DataGridView and BindingSource

          Yeahhhhhh..... ;-)
          I have discovered that the problem occurs only if there are visible
          Scrollbars in the GridView !!! If I disable scrollbars, load data to
          DataSet, then shows it in the datagridview and enabled scrollbars at
          the end, everything works OK ! If I use this trick there is no more
          problem with CurrencyManager .Refresh() :D
          C# MVP check it and eventually correct it (ServicePack 1 for VS 2005
          dosen't help). I think that it is a bug in C#.

          Comment

          Working...