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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GroupBarItems, syncfusion 4.3.0.30 essential tools

Thread ID:

Created:

Updated:

Platform:

Replies:

56034 Feb 8,2007 06:25 PM UTC Feb 9,2007 05:44 PM UTC WinForms 3
loading
Tags: Tools
yarddog
Asked On February 8, 2007 06:25 PM UTC

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,

Gopalakrishnan S [Syncfusion]
Replied On 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.

yarddog
Replied On 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.

Murugan [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;