We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

GroupBarItems, syncfusion 4.3.0.30 essential tools

Hello,

My question is, I have a save, cancel, and reload GroupBarItems that the user can press. I add the items dynamically.

But, once a GroupBarItem is selected, I have to unselect it by assigning a -1 (or it doesn't fire again, because it is already selected)

When I do this, the user can now select any of the items of save, cancel, reload just fine.

The bug appears when they resize the application, the GroupBarItems have to resize, and it throws an exception "System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"

any ideas? (I might just delete the groupbar, use buttons, dock them at the top, but the groupbaritems look cool)


private void GroupBarItem_Selected (object sender, EventArgs e) {
int idx = ((GroupBar)sender).SelectedItem;
string text = ((GroupBar)sender).GroupBarItems[idx].Text;

more code....

// unselect the selected GroupBarItem so
// user can select it again if needed.
((GroupBar)sender).SelectedItem = -1;
}

thanks,

3 Replies

GS Gopalakrishnan S Syncfusion Team February 8, 2007 07:02 PM UTC

Hi Yarddog,

This exception will occur only if resize the GroupBar when selected item set to -1. But in case resize the application (form) it does not through any error. Please try to set size of the GroupBar before the statement of ((GroupBar)sender).SelectedItem = -1; Also, I have created the sample application attached here. Could you please try to reproduce the issue with the attached sample. This will help for us to analyse the issue further.

GroupBarSample.zip


Thanks for using Syncfusion products.

Regards,
S.Gopal.


YA yarddog February 8, 2007 11:07 PM UTC

Thank you for the promt reply. I am now a Syncfusion fan with that kind of support.

First off, your code gave me an idea, and I fixed mine. Plus, I was able to duplicate the error in your code.

Here is what you do for your sample (thanks, that helped)

Right above the this.Controls.Add(groupBar1);

add the line

this.groupBar1.Dock = DockStyle.Top;

Run program
Press Save
Press Cancel
(now, you get the two MessageBoxes with the second message box displaying that it is setting the groupBar1.SelectedItem to -1)

Now, try and resize the form.
It abends with the same error I was getting.

Once I set Dock back to none, it went away.

thanks, this really did help.

Yarddog

>Hi Yarddog,

This exception will occur only if resize the GroupBar when selected item set to -1. But in case resize the application (form) it does not through any error. Please try to set size of the GroupBar before the statement of ((GroupBar)sender).SelectedItem = -1; Also, I have created the sample application attached here. Could you please try to reproduce the issue with the attached sample. This will help for us to analyse the issue further.

GroupBarSample.zip


Thanks for using Syncfusion products.

Regards,
S.Gopal.


MU Murugan Syncfusion Team February 9, 2007 05:44 PM UTC

Hi Yarddog,

Thanks for your sample and detailed reproducing steps.

We could see the issue. The issue could be resolves by firing a userdefined event handler in GroupBar.MouseDown event.

Here is the code snippet:

public delegate void GroupBar_SelectedItemChanged( object sender , EventArgs e );
public event GroupBar_SelectedItemChanged GroupBar_SelectedItemChangedEvent;

private void groupBar1_MouseDown(object sender, MouseEventArgs e)
{

GroupBarItem temp = this.groupBar1.PointToItem( e.X , e.Y );

if ( temp != null )
{

this.groupBar1.SelectedItem = this.groupBar1.GroupBarItems.IndexOf( temp );
if ( this.GroupBar_SelectedItemChangedEvent != null )
{

this.GroupBar_SelectedItemChangedEvent ( sender , new EventArgs () );

}

}
}

Herewith I have attached the sample. Please refer to the sample and let me if it helps you.

GroupBarSample

Thanks,
Murugan P.S

Loader.
Live Chat Icon For mobile
Up arrow icon