Prev: loquendo TTS
Next: layout of ToolStripPanel
From: shibeta on 31 Jan 2007 11:02 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.InvokeRequired) { RefreshUserDetails rud = new RefreshUserDetails(this.refreshBS); this.Invoke(rud); } else { this.DataSet1.AcceptChanges(); this.BindingSource.CurrencyManager.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.BindingSource.CurrencyManager.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.Datagridview.bindingcontext..... 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.
From: RobinS on 1 Feb 2007 04:49 Are you loading your dataset before you set the data source of the bindingsource to the dataset? Robin S. ----------------------------------------- <shibeta(a)wp.pl> wrote in message news:1170259360.884127.102780(a)q2g2000cwa.googlegroups.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.InvokeRequired) > { > RefreshUserDetails rud = new > RefreshUserDetails(this.refreshBS); > this.Invoke(rud); > } > else > { > this.DataSet1.AcceptChanges(); > this.BindingSource.CurrencyManager.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.BindingSource.CurrencyManager.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.Datagridview.bindingcontext..... > 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. >
From: shibeta on 1 Feb 2007 07:17 On 1 Lut, 10:49, "RobinS" <Rob...(a)NoSpam.yah.none> wrote: > 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.
From: shibeta on 1 Feb 2007 10:28 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.
From: shibeta on 2 Feb 2007 08:54 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#.
|
Pages: 1 Prev: loquendo TTS Next: layout of ToolStripPanel |