Robert Gouin
Top achievements
Rank 1
Robert Gouin
asked on 09 Apr 2010, 06:13 PM
I am currently using a good old fashioned
gvDispensing.MasterGridViewTemplate.LoadFrom(openRS(tSQL))
command to load a record set into a grid view.
Some of the data I am working with has 80/150 thousand lines, and when I open the form, it takes over 2 minutes to load the grid view using the code below.
Is there anyway to open the form, and attach a progress bar to this loading process so that the user knows that something is happening?
gvDispensing.MasterGridViewTemplate.LoadFrom(openRS(tSQL))
command to load a record set into a grid view.
Some of the data I am working with has 80/150 thousand lines, and when I open the form, it takes over 2 minutes to load the grid view using the code below.
gvDispensing.MasterGridViewTemplate.AllowAddNewRow = False |
gvDispensing.MasterGridViewTemplate.ShowRowHeaderColumn = False |
gvDispensing.MasterGridViewTemplate.AutoGenerateColumns = True |
gvDispensing.MasterGridViewTemplate.BestFitColumns() |
gvDispensing.GridElement.BeginUpdate() |
tSQL = "Crazy Multi Join Query Here" |
gvDispensing.MasterGridViewTemplate.LoadFrom(openRS(tSQL)) |
Is there anyway to open the form, and attach a progress bar to this loading process so that the user knows that something is happening?
10 Answers, 1 is accepted
0
Hi Robert Gouin,
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
For this scenario you can override your DataReader object and add a Notify event. Here is a simple implementation of SqlDataReader and logic for ProgressBar update:
public
class
MySqlDataReader : SqlDataReader
{
public
event
EventHandler Notify;
public
override
bool
Read()
{
if
(
this
.Notify !=
null
)
{
this
.Notify(
this
,
new
EventArgs());
}
return
base
.Read();
}
}
public
partial
class
Form1 : Form
{
private
int
recordCount = 0;
private
int
currentCount = 0;
public
Form1()
{
InitializeComponent();
//Return Count of records using
SqlCommand command =
new
SqlCommand();
command.CommandText =
"SELECT COUNT('Test')"
;
this
.recordCount = (
int
)command.ExecuteScalar();
MySqlDataReader reader =
new
MySqlDataReader();
reader.Notify +=
new
EventHandler(reader_Notify);
this
.radGridView1.MasterGridViewTemplate.LoadFrom(reader);
}
void
reader_Notify(
object
sender, EventArgs e)
{
currentCount++;
this
.progressBar1.Value = (
int
)((
this
.currentCount / (
double
)
this
.recordCount) * 100);
}
}
Sincerely yours,
Julian Benkovthe Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Robert Gouin
Top achievements
Rank 1
answered on 13 Apr 2010, 05:02 PM
Wow, thank you so much, currently as a MS patch all I did was make the load a background working and have a waiting bar just keep going and going until it was done with no progress indication what-so-ever. It reminded me of the old VB installer when the bar really meant nothing but it was a moving bar lol.
0
Robert Gouin
Top achievements
Rank 1
answered on 13 Apr 2010, 05:04 PM
By any chance do you have the VB.net equivalent to this code?
0
Hi Robert Gouin,
You can use our online converter to do this for you. We have done this for your convenience, so here is the VB version:
Regards,
Julian Benkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
You can use our online converter to do this for you. We have done this for your convenience, so here is the VB version:
Public
Class
MySqlDataReader
Inherits
SqlDataReader
Public
Event
Notify
As
EventHandler
Public
Overloads
Overrides
Function
Read()
As
Boolean
RaiseEvent
Notify(
Me
,
New
EventArgs())
Return
MyBase
.Read()
End
Function
End
Class
Public
Partial
Class
Form1
Inherits
Form
Private
recordCount
As
Integer
= 0
Private
currentCount
As
Integer
= 0
Public
Sub
New
()
InitializeComponent()
'Return Count of records using
Dim
command
As
New
SqlCommand()
command.CommandText =
"SELECT COUNT('Test')"
Me
.recordCount =
CInt
(command.ExecuteScalar())
Dim
reader
As
New
MySqlDataReader()
AddHandler
reader.Notify,
AddressOf
reader_Notify
Me
.radGridView1.MasterGridViewTemplate.LoadFrom(reader)
End
Sub
Private
Sub
reader_Notify(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
currentCount += 1
Me
.progressBar1.Value =
CInt
(((
Me
.currentCount /
CDbl
(
Me
.recordCount)) * 100))
End
Sub
End
Class
Julian Benkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
luke johnson
Top achievements
Rank 1
answered on 30 Mar 2012, 10:32 PM
I am using an object to populate my GridView Datasource, is there a simple way of using the status strip/progress bar to indicate that the data is loading?
0
Hi Luke,
There is no way to handle this scenario in RadGridView control. You can implement this functionality when you prepare your data source object. Additionally, in the DataBindingComplete event of RadGridView you can perform the last step (for example the last 10%) of the work completion.
If you have other questions, do not hesitate to contact me again.
Regards,
Julian Benkov
the Telerik team
There is no way to handle this scenario in RadGridView control. You can implement this functionality when you prepare your data source object. Additionally, in the DataBindingComplete event of RadGridView you can perform the last step (for example the last 10%) of the work completion.
If you have other questions, do not hesitate to contact me again.
Regards,
Julian Benkov
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Yaroslav
Top achievements
Rank 1
answered on 25 Apr 2012, 09:45 AM
Hi, I'm interested also on showing a progess bar for some of the data loading process I have as some of them take some time to finish. I typically use binding sources of the datasource of the grids or either directly setup the datasource and datamember fields of the grid. Tried the recommende approach but without success.
It will be usefull if a code snippet is provided to use it as base...thanks!
It will be usefull if a code snippet is provided to use it as base...thanks!
0
Hi Yaroslav,
the Telerik team
This functionality closely depends on your binding object and its loading mechanism. Please share with us code snippets of the logic that you have to load your data source object. This will allow us to assist you further.
Thank you for your cooperation. I am looking forward to your reply.
All the best,
Julian Benkovthe Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Yaroslav
Top achievements
Rank 1
answered on 27 Apr 2012, 02:36 PM
Hi, I believe a code snippet will not help too much as the scenario can be different each time. I usually setup all the enviroment coding and what I usually do is:
On user request I call the method on the table adapter and then gridview.refresh()
Hope it helps.
- create dataset and assign an existing dataset from my existing model
- create binding source, set datasource to previously created dataset and set the needed datamemeber
- create a table adapter with a method to, either call a stored procedure or execute a query
- create a gridview and binding it to the binding source created on the 2nd step
On user request I call the method on the table adapter and then gridview.refresh()
Hope it helps.
0
Hello Yaroslav,
The DataSet, DataTable and DbAdapter types do not support this functionality. The only possible solution in this situation is to use segmented version of Fill method of your adapter and update progressbar based on this segmentation. Here is a description of this method from ADO.NET:
I hope this helps.
All the best,
Julian Benkov
the Telerik team
The DataSet, DataTable and DbAdapter types do not support this functionality. The only possible solution in this situation is to use segmented version of Fill method of your adapter and update progressbar based on this segmentation. Here is a description of this method from ADO.NET:
//
// Summary:
// Adds or refreshes rows in a System.Data.DataTable to match those in the data
// source starting at the specified record and retrieving up to the specified
// maximum number of records.
//
// Parameters:
// startRecord:
// The zero-based record number to start with.
//
// maxRecords:
// The maximum number of records to retrieve.
//
// dataTables:
// The System.Data.DataTable objects to fill from the data source.
//
// Returns:
// The number of rows successfully added to or refreshed in the System.Data.DataTable.
// This value does not include rows affected by statements that do not return
// rows.
public
int
Fill(
int
startRecord,
int
maxRecords,
params
DataTable[] dataTables);
I hope this helps.
All the best,
Julian Benkov
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>