atlind
asked on
Arraylist StringFormat / StringAlignment Problem vb.net vb code
I have an arraylist filled with text that is used to populate a bunch of drawable text. I include in the arraylist a stringformat collection which is built from a file.
My problem is this, when ever I change stringformat.stringalignme nt.alignme nt, VB wants to update the value of alignment in all the text in the arraylist. All I really want to do is to store the Near, Center and Far inforamtion and use it to format the text when the drawabletext box is created at runtime. Any Ideas why the arraylist might be updated in the manner.
My problem is this, when ever I change stringformat.stringalignme
ASKER
Thanks for the response....
It would be difficult to post the code as it spans several files. But basically I have a text file that contains all the information I need to create a drawable text box.
ex..
ForeColor = Green
BackColor = Blue
Text = Some Text
Font = Arial, 12, Bold
Alignment = Center
I then read this file covert colors from text to Hex Color, Convert Font text to .font and convert Alignment into a StringFormat with the alignment set at what ever the text file has in it.
Now this file contains hundreds of text info blocks so I collect the information from one text block, do any conversion I need and store the converted info into an arraylist, then repeat for each text block in the file.
This issue I am having with the arraylist, is when ever I add a new set of information to the arraylist, when the stringformat inforation is added to the arraylist, all previously stored stringformat information is updated to match the most recently added info.
Example
Arraylist(0).stringformat. alignment = Center
Arraylist(1).stringformat. alignment = Center
Arraylist(2).stringformat. alignment = Far
In this example as soon as I store the info for the "Far" alignment I will get the following...
Arraylist(0).stringformat. alignment = Far
Arraylist(1).stringformat. alignment = Far
Arraylist(2).stringformat. alignment = Far
Likewise if I add Arraylist(3).stringformat. alignment = Near, then I get..
Arraylist(0).stringformat. alignment = Near
Arraylist(1).stringformat. alignment = Near
Arraylist(2).stringformat. alignment = Near
Arraylist(3).stringformat. alignment = Near
Hope this is a little more clear...
I know this may be troublesome to understand without the code, but my bose would not be none to happy If I put it on display...lol
It would be difficult to post the code as it spans several files. But basically I have a text file that contains all the information I need to create a drawable text box.
ex..
ForeColor = Green
BackColor = Blue
Text = Some Text
Font = Arial, 12, Bold
Alignment = Center
I then read this file covert colors from text to Hex Color, Convert Font text to .font and convert Alignment into a StringFormat with the alignment set at what ever the text file has in it.
Now this file contains hundreds of text info blocks so I collect the information from one text block, do any conversion I need and store the converted info into an arraylist, then repeat for each text block in the file.
This issue I am having with the arraylist, is when ever I add a new set of information to the arraylist, when the stringformat inforation is added to the arraylist, all previously stored stringformat information is updated to match the most recently added info.
Example
Arraylist(0).stringformat.
Arraylist(1).stringformat.
Arraylist(2).stringformat.
In this example as soon as I store the info for the "Far" alignment I will get the following...
Arraylist(0).stringformat.
Arraylist(1).stringformat.
Arraylist(2).stringformat.
Likewise if I add Arraylist(3).stringformat.
Arraylist(0).stringformat.
Arraylist(1).stringformat.
Arraylist(2).stringformat.
Arraylist(3).stringformat.
Hope this is a little more clear...
I know this may be troublesome to understand without the code, but my bose would not be none to happy If I put it on display...lol
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ah perfect I knew it had to be simple...lol
Thank you so very much. You were absolutely correct!!! Well Done!
Thank you so very much. You were absolutely correct!!! Well Done!
ASKER
Perfect! Thank You Very Much!
How do you include it? Sounds like you have one object that you are updating as you go instead of new objects that you are adding to the collection. Post your code and we can fix it.