By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,493 Members | 3,101 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,493 IT Pros & Developers. It's quick & easy.

Need to re-create code in new control (please help)

P: n/a
Thanks for reading this...

Our current Win app employs a ListView control wherein the tag for an item
is, for example, "ContentManager.DataModel.PowerPointContent". The
following code exists (and works just fine) for when the user clicks on any
item within the ListView:

private void listView1_MouseClick( object sender, MouseEventArgs e )
{
Type listItemType = (Type)( ( sender as ListView ).FocusedItem.Tag );
Content newContent = (Content)Activator.CreateInstance( listItemType );
AddContent( newContent );
}

However, I'm now tasked with replacing the ListView control with ListBar
control from Infragistics. While I can easily determine which item is
clicked from e.Item.Tag, I'm not understanding how to write code in this
event:

private void ultraListBar1_ItemSelected(object sender,
Infragistics.Win.UltraWinListBar.ItemEventArgs e)
{
???
}

If anyone can help me out, I will gladly buy them a beer.

Thanks very much,
Ron
Jan 11 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
What are you trying to achieve via that event?
Infragistics has its own NG, full of answers. Did you get the chance to try
that?
"Ronald S. Cook" <rc***@westinis.com> wrote in message
news:uL**************@TK2MSFTNGP09.phx.gbl...
Thanks for reading this...

Our current Win app employs a ListView control wherein the tag for an item
is, for example, "ContentManager.DataModel.PowerPointContent". The
following code exists (and works just fine) for when the user clicks on
any item within the ListView:

private void listView1_MouseClick( object sender, MouseEventArgs e )
{
Type listItemType = (Type)( ( sender as ListView ).FocusedItem.Tag );
Content newContent = (Content)Activator.CreateInstance( listItemType );
AddContent( newContent );
}

However, I'm now tasked with replacing the ListView control with ListBar
control from Infragistics. While I can easily determine which item is
clicked from e.Item.Tag, I'm not understanding how to write code in this
event:

private void ultraListBar1_ItemSelected(object sender,
Infragistics.Win.UltraWinListBar.ItemEventArgs e)
{
???
}

If anyone can help me out, I will gladly buy them a beer.

Thanks very much,
Ron

Jan 11 '06 #2

P: n/a
Something like this maybe...

private void ultraListBar1_ItemSelected (object sender, Infragistics.Win.UltraWinListBar.ItemEventArgs
e)
{
Content newContent = e.Item.Tag as Content;
if (newContent != null)
AddContent(newContent);
}
Thanks for reading this...

Our current Win app employs a ListView control wherein the tag for an
item is, for example, "ContentManager.DataModel.PowerPointContent".
The following code exists (and works just fine) for when the user
clicks on any item within the ListView:

private void listView1_MouseClick( object sender, MouseEventArgs e )
{
Type listItemType = (Type)( ( sender as ListView ).FocusedItem.Tag );
Content newContent = (Content)Activator.CreateInstance( listItemType
);
AddContent( newContent );
}
However, I'm now tasked with replacing the ListView control with
ListBar control from Infragistics. While I can easily determine which
item is clicked from e.Item.Tag, I'm not understanding how to write
code in this event:

private void ultraListBar1_ItemSelected(object sender,
Infragistics.Win.UltraWinListBar.ItemEventArgs e)
{
???
}
If anyone can help me out, I will gladly buy them a beer.

Thanks very much,
Ron

Jan 11 '06 #3

P: n/a

Ronald S. Cook wrote:
Thanks for reading this...

Our current Win app employs a ListView control wherein the tag for an item
is, for example, "ContentManager.DataModel.PowerPointContent". The
following code exists (and works just fine) for when the user clicks on any
item within the ListView:

private void listView1_MouseClick( object sender, MouseEventArgs e )
{
Type listItemType = (Type)( ( sender as ListView ).FocusedItem.Tag );
Content newContent = (Content)Activator.CreateInstance( listItemType );
AddContent( newContent );
}

However, I'm now tasked with replacing the ListView control with ListBar
control from Infragistics. While I can easily determine which item is
clicked from e.Item.Tag, I'm not understanding how to write code in this
event:

private void ultraListBar1_ItemSelected(object sender,
Infragistics.Win.UltraWinListBar.ItemEventArgs e)
{
???
}

If anyone can help me out, I will gladly buy them a beer.
Eh, keep the beer. I'd probably end up with Schlitz or something :)

Seriously, I have no idea what the Infragistics ListBar is. However,
assuming that
the Tag item is the same...

Type listItemType = (Type)( ( e.Item.Tag ); Content newContent = (Content)Activator.CreateInstance( listItemType );
AddContent( newContent );


Is that what you are looking for?

Matt

Jan 11 '06 #4

P: n/a
Ron,
I've never used their control, but looking at the signature, shouldn't it be
something like:

private void ultraListBar1_ItemSelected(object sender,
Infragistics.Win.UltraWinListBar.ItemEventArgs e)
{
Type UltraListBar.Item = (Type)( ( sender as UltraListBar ).SelectedItem.Tag
);
Content newContent = (Content)Activator.CreateInstance( UlttraListBar.Item );
AddContent( newContent );
}

-- where UltraListBar.Item is whatever their defined ListBar item is.

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Ronald S. Cook" wrote:
Thanks for reading this...

Our current Win app employs a ListView control wherein the tag for an item
is, for example, "ContentManager.DataModel.PowerPointContent". The
following code exists (and works just fine) for when the user clicks on any
item within the ListView:

private void listView1_MouseClick( object sender, MouseEventArgs e )
{
Type listItemType = (Type)( ( sender as ListView ).FocusedItem.Tag );
Content newContent = (Content)Activator.CreateInstance( listItemType );
AddContent( newContent );
}

However, I'm now tasked with replacing the ListView control with ListBar
control from Infragistics. While I can easily determine which item is
clicked from e.Item.Tag, I'm not understanding how to write code in this
event:

private void ultraListBar1_ItemSelected(object sender,
Infragistics.Win.UltraWinListBar.ItemEventArgs e)
{
???
}

If anyone can help me out, I will gladly buy them a beer.

Thanks very much,
Ron

Jan 11 '06 #5

P: n/a
Thanks for this code snippet, Matt, but it gives me the following error at
runtime:

Unable to cast object of type 'System.String' to type 'System.Type'.

Any thoughts? I sincerely appreciate the help.

Ron

"Matt" <ma********@sprynet.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...

Ronald S. Cook wrote:
Thanks for reading this...

Our current Win app employs a ListView control wherein the tag for an
item
is, for example, "ContentManager.DataModel.PowerPointContent". The
following code exists (and works just fine) for when the user clicks on
any
item within the ListView:

private void listView1_MouseClick( object sender, MouseEventArgs e )
{
Type listItemType = (Type)( ( sender as ListView ).FocusedItem.Tag );
Content newContent = (Content)Activator.CreateInstance( listItemType );
AddContent( newContent );
}

However, I'm now tasked with replacing the ListView control with ListBar
control from Infragistics. While I can easily determine which item is
clicked from e.Item.Tag, I'm not understanding how to write code in this
event:

private void ultraListBar1_ItemSelected(object sender,
Infragistics.Win.UltraWinListBar.ItemEventArgs e)
{
???
}

If anyone can help me out, I will gladly buy them a beer.


Eh, keep the beer. I'd probably end up with Schlitz or something :)

Seriously, I have no idea what the Infragistics ListBar is. However,
assuming that
the Tag item is the same...

Type listItemType = (Type)( ( e.Item.Tag );
Content newContent = (Content)Activator.CreateInstance( listItemType );
AddContent( newContent );


Is that what you are looking for?

Matt

Jan 11 '06 #6

P: n/a
Thanks so much, Peter. I tried the following code (which did build
successfully):

Type UltraWinListBar = (Type)((sender as
Infragistics.Win.UltraWinListBar.Item).Tag);
Content newContent = (Content)Activator.CreateInstance(UltraWinListBar) ;
AddContent(newContent);

But got the following error at runtime:

"Object reference not set to an instance of an object."

Any thoughts? I greatly appreciate the help!

Ron

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:AD**********************************@microsof t.com...
Ron,
I've never used their control, but looking at the signature, shouldn't it
be
something like:

private void ultraListBar1_ItemSelected(object sender,
Infragistics.Win.UltraWinListBar.ItemEventArgs e)
{
Type UltraListBar.Item = (Type)( ( sender as
UltraListBar ).SelectedItem.Tag
);
Content newContent = (Content)Activator.CreateInstance(
UlttraListBar.Item );
AddContent( newContent );
}

-- where UltraListBar.Item is whatever their defined ListBar item is.

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Ronald S. Cook" wrote:
Thanks for reading this...

Our current Win app employs a ListView control wherein the tag for an
item
is, for example, "ContentManager.DataModel.PowerPointContent". The
following code exists (and works just fine) for when the user clicks on
any
item within the ListView:

private void listView1_MouseClick( object sender, MouseEventArgs e )
{
Type listItemType = (Type)( ( sender as ListView ).FocusedItem.Tag );
Content newContent = (Content)Activator.CreateInstance( listItemType );
AddContent( newContent );
}

However, I'm now tasked with replacing the ListView control with ListBar
control from Infragistics. While I can easily determine which item is
clicked from e.Item.Tag, I'm not understanding how to write code in this
event:

private void ultraListBar1_ItemSelected(object sender,
Infragistics.Win.UltraWinListBar.ItemEventArgs e)
{
???
}

If anyone can help me out, I will gladly buy them a beer.

Thanks very much,
Ron

Jan 11 '06 #7

P: n/a

Ronald S. Cook wrote:
Thanks for this code snippet, Matt, but it gives me the following error at
runtime:

Unable to cast object of type 'System.String' to type 'System.Type'.

Any thoughts? I sincerely appreciate the help.
Hm. Its telling you that the object stored in the Tag member is a
String,
rather than a type. This isn't really a problem, you can create an
object
from a NAME of a type.

Take a look at System.Activator.CreateInstance.

Matt

Ron

"Matt" <ma********@sprynet.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...

Ronald S. Cook wrote:
Thanks for reading this...

Our current Win app employs a ListView control wherein the tag for an
item
is, for example, "ContentManager.DataModel.PowerPointContent". The
following code exists (and works just fine) for when the user clicks on
any
item within the ListView:

private void listView1_MouseClick( object sender, MouseEventArgs e )
{
Type listItemType = (Type)( ( sender as ListView ).FocusedItem.Tag );
Content newContent = (Content)Activator.CreateInstance( listItemType );
AddContent( newContent );
}

However, I'm now tasked with replacing the ListView control with ListBar
control from Infragistics. While I can easily determine which item is
clicked from e.Item.Tag, I'm not understanding how to write code in this
event:

private void ultraListBar1_ItemSelected(object sender,
Infragistics.Win.UltraWinListBar.ItemEventArgs e)
{
???
}

If anyone can help me out, I will gladly buy them a beer.


Eh, keep the beer. I'd probably end up with Schlitz or something :)

Seriously, I have no idea what the Infragistics ListBar is. However,
assuming that
the Tag item is the same...

Type listItemType = (Type)( ( e.Item.Tag );
Content newContent = (Content)Activator.CreateInstance( listItemType );
AddContent( newContent );


Is that what you are looking for?

Matt


Jan 12 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.