Profile Picture

NComboBox.Items[ ].Tag is overwritten?

Posted By Miles Thornton 14 Years Ago
Author
Message
Angel Chorbadzhiev
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)

Group: Forum Members
Last Active: Last Month
Posts: 139, Visits: 184

Hi Miles,

Try to add the items as follows:

NListBoxItem item = new NListBoxItem();

item.Text = _FixtureBodiesList.FixtureBodies[i].Description;

item.Tag = _FixtureBodiesList.FixtureBodies[i].FixtureBody_IDX;

this.ncboFixturesFixtureBody.Items.Add(item);

Please, let me know if the problems still persist.

Regards,

Angel.

 



Miles Thornton
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 17, Visits: 1

Angel,

Thank you for the reply, but, perhaps I wasn't as clear as I needed to be...

I am not setting the Tag property of the NComboBox.Item to the value of the NComboBox.Text; it appears that the Neveron control is doing so.

I am setting the Tag property to the integer KEY value I need and the control is resetting the value on its own.

This is causing me to lose the KEY value pairing I need to quickly find and save the object data!

For example, I load the NComboBox:

string FixtureBodyListFile = System.Configuration.ConfigurationManager.AppSettings["FixtureBodiesListFile"].ToString();

FixtureBodyList _FixtureBodiesList = FixtureBodyList.Deserialize(FixtureBodyListFile);

this.ncboFixturesFixtureBody.Items.Clear();

for (int i = 0; i < _FixtureBodiesList.FixtureBodies.Length; i++)

{

this.ncboFixturesFixtureBody.Items.Add(_FixtureBodiesList.FixtureBodies[i].Description);

this.ncboFixturesFixtureBody.Items[i].Tag = _FixtureBodiesList.FixtureBodies[i].FixtureBody_IDX;

}

Then later, when I go to USE the Tag value; my Key value is gone; replaced by the control with the TEXT value... 

I've checked, there is nowhere else that I modify the Key value. I do allow the user to modify the TEXT value; but that should not alter the Tag (Key); right?

I'm thinking I may be reporting a bug here! Please let me know if I need to send more information...



Angel Chorbadzhiev
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)

Group: Forum Members
Last Active: Last Month
Posts: 139, Visits: 184

Hi Miles,

The only case where you can set the Tag property to be equal to Text property is when you use NListBoxItem(object o) constructor to create an item and o parameter is string.

However, if you set Tag property after creation of the item using this constructor it should remain as you set it.

Regards,

Angel.



Miles Thornton
questionmark Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)Junior Member (17 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 17, Visits: 1

I have noticed a behavior that is causing me problems; IDK if this is a Nevron bug or not. Can I get someone to look at this for me?

Since I manually load the Combo-Box picklist Items[<n>].Text with the description, I use the Items[<n>].Tag to hold the DB integer Key value of the record so I can locate it later for posting back to the DB.

Unfortunately, the Nevron NComboBox.Items[<n>].Tag is being overwritten by the contents of the .Items[<n>].Text property by the time I go to get it.

So, this operation, which works well with native components, fails:

int keyValue = int.Parse(this.ncboPreFixturesList.Items[this.ncboPreFixturesList.SelectedIndex].Tag.ToString());

Are you guys doing this? I haven't been able to find a place in my code where this could be happening...

Thanks,

-Miles





Similar Topics


Reading This Topic