Find a toolbarcheckbuttoncollection control on a IE toolbar contro

W

William Main

I have an Internet Explorer Toolbar with a ToolBarCheckButtonCollection on
it. I am trying to access this collection so that I can check the Selected
property of one of the buttons. I tried

ToolbarCheckButtonCollection grpMove = this.Toolbar1.Items[12];

but I get an error on compile

C:\Inetpub\wwwroot\GroupView\PayrxTreeView.ascx.cs(237): Cannot implicitly
convert type 'Microsoft.Web.UI.WebControls.ToolbarItem' to
'Microsoft.Web.UI.WebControls.ToolbarCheckButtonCollection'

How do I access the group?

Once I've properly addressed the group I ham hoping that I can simply use

ToolbarCheckButton chkGroup = grpMove[0];

to address the first button in the group.
 
S

Steven Cheng[MSFT]

Hi William,

Welcome to ASPNET newsgroup. As for the problem on accessing the ToolBar IE
webcontrol's Items collection you mentioned, I think the error is caused by
you using the

ToolbarCheckButtonCollection to reference to a ToolbarCheckGroup Item.

We need to change the code as below:

ToolbarCheckGroup checkGroup = tbMain.Items[2] as ToolbarCheckGroup;

if(checkGroup != null)
{
foreach(ToolbarCheckButton button in checkGroup.Items)
{
Response.Write(string.Format("<br>id:{0},
text:{1}",button.ID,button.Text));
}
}

In fact, the ToolbarCheckButtonCollection is the type of the
ToolbarCheckGroup.Items property.

Also, I think we can always print out all the items's type of the Toolbar's
Items collection before acessing them so that we can make sure what's the
reference type can should use, for example:

foreach( ToolbarItem item in tbMain.Items)
{
Response.Write("<br>id:" + item.ID + " | " + item.GetType().ToString());
}


BTW, the IE webcontrol will no longer be updated and supported and the
asp.net 2.0 will integrated them into the buildin webcontrols set. You can
get the latest beta preview version to have a look.

Enjoy ASP.NET :)

Thanks & Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,142
Messages
2,570,819
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top