Solved

How To Question

Posted on 2014-01-25
6
201 Views
Last Modified: 2014-05-20
Hello~

Working on a C# Visual Studios 2010 project trying to create something but having some issues. Does anyone have any suggestions on what to use when you have a list of items and you want to select one of those items, look at it, then you click on another item and look at it, without getting a ArgumentOutOfRangeException? The first item can be clicked with no error. Second item throws the error. You can click continue and it shows the item but it always throws the error. Have tried using ItemsSelectionChanged and that is what is giving the error right now. If you can just give some direction at this point on what to try that would be great.

Thanks
D
0
Comment
Question by:dminx13
  • 3
  • 3
6 Comments
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 39810135
Well without seeing the code and knowing which control/s you are using or if the second click is in a different control it is difficult to tell.

Let say you are clicking on the same control maybe a ListBox, to select multiple items you need to set SelectionMode to Multiple.

Please post more information and code and the exception message and inner exception message.
0
 

Author Comment

by:dminx13
ID: 39810619
 private void InvTree_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            int h = e.Item.Index;
            inventory1.comboList1.ResetComboTree();
            inventory1.valueStrip1.Reset();
            var ItemData = savefile.items.items[InvTree.SelectedItems[0].Index];
            inventory1.valueStrip1.dye = Convert.ToInt32(ItemData.generator.dye_type);
            inventory1.valueStrip1.binding = Convert.ToInt32(ItemData.generator.item_binding_level);
            inventory1.valueStrip1.hireling = Convert.ToInt32(ItemData.hireling_class);
            inventory1.valueStrip1.Durability.Value = ItemData.generator.durability;
            inventory1.valueStrip1.Flags.Value = ItemData.generator.flags;
            inventory1.valueStrip1.legendary_item_level.Value = ItemData.generator.legendary_item_level;
            inventory1.valueStrip1.itemqualitylevel = ItemData.generator.item_quality_level;
            inventory1.valueStrip1.Max_Durability.Value = ItemData.generator.max_durability;
            inventory1.valueStrip1.stack_size.Value = ItemData.generator.stack_size;
            var rare_item_name = ItemData.generator.rare_item_name;
            try
            {
                inventory1.comboList1.sno_affix_string_list.Value = rare_item_name.sno_affix_string_list;
                inventory1.comboList1.item_name_is_prefix.Checked = rare_item_name.item_name_is_prefix;
                inventory1.comboList1.item_string_list_index.Value = rare_item_name.item_string_list_index;
                inventory1.comboList1.affix_string_list_index.Value = rare_item_name.affix_string_list_index;
            }
            catch { }
            this.inventory1.comboList1.SetComboTree((ComboTreeBox)this.inventory1.comboList1.ComboLayout.GetControlFromPosition(1, 0), ItemData.generator.gb_handle.gbid.ToString());
            for (int i = 0; i <= ItemData.generator.base_affixes.Count - 1; i++)
            {
                if (ItemData.generator.base_affixes.Count > 0)
                    this.inventory1.comboList1.SetComboTree((ComboTreeBox)this.inventory1.comboList1.ComboLayout.GetControlFromPosition(1, i + 1), ItemData.generator.base_affixes[i].ToString());
            }

Open in new window

0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 39810691
Please post more information and the exception message and inner exception message. Please also indicate on which line it occurs on.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:dminx13
ID: 39810725
Error occurs on line 6. ArgumentOutOfRangeException was unhandled. See attached screenshot.
c--Error.png
0
 

Author Comment

by:dminx13
ID: 39871372
Wondering if anyone has anything more on this. I added code and error and no one has responded. I have been pulled off the project so if I don't hear anything I'll just delete this question. Thanks!
Deanna
0
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 39872374
Run the program, when it throws the exception highlight this part of the statement on line 6,
InvTree.SelectedItems[0].Index , the right click on the highlighted part of the line and select "Add Watch". If the Watch windows was not open at the bottom of the window it will open. What is the vale in the Value column? Also what is the value in the Type column.

Also in the Exception dialog box click on the words "View Detail...", Another window will open  expand the only node, along the left side find the line with Inner Exception and post the value on that line if it has a value in it.

By the look of the exception you posted it looks as if the value might be a 'O' and not a digit.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question