Solved

How To Question

Posted on 2014-01-25
6
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 63

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 63

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 63

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

735 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