Hi,
Do you guys have some complete example on how to use the UltraProgressBar, using a seperate thread for it to run on ? Using the BackroundWorker for example ...
I ran into this example but it's horrible ( no offense ) ... it's not handling all the events of the BackroundWorker for example, http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=9838
I need to use the UltraProgressBar while seeking data for multiple controls ... because it takes approx 5 seconds to load all the controls ... It should fire up after the user selects a new entry from a DropDown Box ( the box is CSLA databound, and fires of loads of events when selected_item_changed fires ... )
Do you have a complete example on how to use it IN CODE for me ?
Thanx in advance,EE.
I attached a demo
Hi Brian,
Thanx for the demo ... but as usually the demo's are so simple ( from the Net ) ...
I don't have any counter for getting the data ... e.g. how many items etc. They're all taken from the database at once
So I can't anything like this ... some int counter:for ( int i = 0; i < 100; i ++ ) { if ( this.taskCanceled ) { e.Cancel = true; this.BeginInvoke( new MethodInvoker(this.OnTaskComplete) ); break; } System.Threading.Thread.Sleep( TimeSpan.FromSeconds(1) ); worker.ReportProgress( i ); }
I have a "Manager" class which the Form uses to populate it's data ...
I'm getting the data OnPropertyChanged on a databound UltraCombo ...which is then databound to a CSLA List class ...
So here's how I load the data ( in the Manager class ):
The "SelectedProjectID" is databound to a UltraCombo, Value field ...Have a look at this line in particular, it gets the data:this.LoadProperty(_currentProjectProperty, Project.GetParticularProjectsByUsernameAndEmployeeTypeId(this.SelectedProjectID, Username, EmployeeTypeID));
This is fired when the property in the UltraGrid changes ( because the SelectedProjectID is databound to that UltraCombo for available projects) :protected override void OnPropertyChanged(string propertyName) { base.OnPropertyChanged(propertyName); if (propertyName != "CanSave") { if (CurrentProject != null) CanSave = this.IsSavable && CurrentProject.IsSavable; } if (propertyName == "SelectedProjectID") { //Remove the <Please Select A Project> if this is the FIRST time a project is being selected ... if (this.AvailableProjects.FirstOrDefault(x => x.Key == 0) != null) this.AvailableProjects.Remove(this.AvailableProjects.First(x => x.Key == 0)); //eyðir "<Please Select A Project>" ... sem ætti bara að vera í **1sta** skipið sem keyrt er inn í AddNewProject() //TODO: bjóða notanda upp á að vista ef að CurrentProject er Dirty: if (this.CurrentProject != null) { if (this.CurrentProject.IsDirty) { this.LoadProperty(_previouslySelectedProjectIDProperty, SelectedProjectID); this.LoadProperty(_needToPromptForLastSelectedProjectProperty, true); PreviouslyUnsavedProject = CurrentProject; } } //just to make sure the grid is only displaying 1 project: this.LoadProperty(_currentProjectsProperty, ProjectList.NewList()); //Gert svona, því ekki er hægt að CLEAR'a CSLA rót if (SelectedProjectID > 0) //if 0 ... New project is being created { this.LoadProperty(_currentProjectProperty, Project.GetParticularProjectsByUsernameAndEmployeeTypeId(this.SelectedProjectID, Username, EmployeeTypeID)); //CurrentProject = Project.GetParticularProjectsByUsernameAndEmployeeTypeId(this.SelectedProjectID, Username, EmployeeTypeID); this.CurrentProjects.Add(CurrentProject); } } }
Then this fires, AFTER the Manager has fetched the data:
private void _cbAvailableProjects_SelectedIndexChanged(object sender, EventArgs e) { if (_projectManager.CurrentProject != null) { //This will trigger the save of a previously unsaved data: if (_projectManager.NeedToPromptForLastSelectedProject == true) { DialogResult dr = MessageBox.Show("Please note that you have not saved your previous Project" + Environment.NewLine + "do you want to save?", "Previous Project not saved", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dr == DialogResult.Yes) { if (_projectManager.PreviouslyUnsavedProject.IsSavable) { _projectManager.PreviouslyUnsavedProject.Save(); } else { MessageBox.Show("The Project is not valid" + Environment.NewLine + "Please fix the Project before saving", "Project is not savable", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } //Reset the flag, which was set as true in the Manager: _projectManager.NeedToPromptForLastSelectedProject = false; _cbAvailableProjects.SelectedValue = _projectManager.SelectedProjectID; //to trigger the change if previous selected project was changed. //Then the other binding lists... needed ... to update the binding source controls with latest status of entities ( e.g. "IsDirty" etc ): _currentProjectbindingSource.DataSource = _projectManager.CurrentProject; //this one binds to all the properties for the current project _projectMembersBindingSource.DataSource = _projectManager.CurrentProject.Members; _projectSteeringCommitteebindingSource.DataSource = _projectManager.CurrentProject.SteeringCommittees; _cbAvailableProjects.SelectedValue = _projectManager.CurrentProject.ProjectID; //now we might have something to save, only needed if the user can edit the project if (Managers.ProjectManager.CanEditObject()) _btnSaveProject.Visible = true; } _branchesBindingSource.DataSource = _projectManager.AvailableBranches; }
How would you load the progressbar in my scenario ?
Kind regards,EE
Good idea, didn't know about this control ... have an example on how this control is used ?
Is this simply used like this ?It doesn't take more than a few ( 2-3 ) seconds to do the change ...
Would you recommend running this on a seperate thread or what ? I need an example ....
private void _btnSaveProject_Click(object sender, EventArgs e) { ultraActivityIndicator1.Visible = true; ultraActivityIndicator1.Show(); ultraActivityIndicator1.Start(); UnbindControlsAndSaveProject(); ultraActivityIndicator1.Stop(); ultraActivityIndicator1.Visible = false; }
Kind regards,EE.
I'm not sure I understand what you are trying to do here. Are you saying that you want to use a ProgressBar to show progress, but you do not know the total number of operations that will occur? If that's the case, then I don't see how you could use a ProgressBar.
How your code is operating and performing the operations you are reporting the progress of doesn't really matter. In order for this to work, you have to be able to calculate what the percentage of the progressbar should be at any given time. If you don't know the total number of operations, then that is not possible. You might want to consider using the UltraActivityIndicator in such a case.