NavBarControl.BeginUpdate() Method
Locks the NavBarControl object by preventing visual updates of the object and its elements until the EndUpdate method is called.
Namespace: DevExpress.XtraNavBar
Assembly: DevExpress.XtraNavBar.v24.2.dll
Declaration
Remarks
The BeginUpdate and EndUpdate methods allow you to avoid flickering while performing batch modifications to the NavBarControl‘s settings. Once the BeginUpdate method has been called, modifying settings of the NavBarControl and its elements does not cause an immediate visual update. So, multiple modifications can be made to the object and its elements without a major impact on performance or screen flickering. After all the desired operations have been finished, call the EndUpdate method.
The BeginUpdate and EndUpdate methods use an internal counter to implement the update functionality. The counter’s initial value is 0. Visual updates are forbidden if the counter’s value is greater than 0, and the updates are enabled if the counter’s value is 0. The BeginUpdate method increments the counter. The EndUpdate method decrements the counter. If the counter’s new value is 0, an immediate visual update occurs. Each call to BeginUpdate must be paired with a call to EndUpdate. To ensure that EndUpdate is always called even if an exception occurs, use the try…finally statement.
Example
The following sample code assigns background images to the XtraNavBar and its groups. The NavBarGroup.BackgroundImage and NavBarControl.GroupBackgroundImage properties are used for this purpose. The NavBarControl.BeginUpdate
and NavBarControl.EndUpdate methods are used to avoid repeated redrawing when changes are implemented.
The image below shows the nav bar before and after the code below has been executed.
navBarControl1.BeginUpdate();
// Assigning an image to the control's background.
navBarControl1.BackgroundImage = Image.FromFile("C:\\Images\\Textures\\controlBack.gif");
// Making the control's background transparent.
navBarControl1.Appearance.Background.BackColor = Color.FromArgb(0, 0, 0, 0);
// Assigning an image to the background of the groups.
navBarControl1.GroupBackgroundImage = Image.FromFile("C:\\Images\\Textures\\groupsBack.gif");
// Making the background transparent.
navBarControl1.Appearance.GroupBackground.BackColor = Color.FromArgb(0, 0, 0, 0);
navBarControl1.EndUpdate();