PC Review


Reply
Thread Tools Rate Thread

arraylist - childmdifrm.Activate - how?

 
 
Adda
Guest
Posts: n/a
 
      13th Apr 2004
In a Parent mdi form I have a datagrid. I select a record
from the grid and then invoke a childmdi form. I add the
childmdi to an arraylist to keep track of it. If a user
has selected multiple records from the grid and has
multiple childmdi forms open and then re-selects a
previously selected record, I want to activate that
childmdi form. Suppose the arraylist contains indexes
0,1,2,3,4 (5 childmdi forms). A user re-selects a child
at index 2. How can I activate that childform?
Pseudocode:
dim arrayfrms As New Arraylist
....
arrayfrms(2).Activate

TIA
Adda
 
Reply With Quote
 
 
 
 
Adda
Guest
Posts: n/a
 
      13th Apr 2004
Thank you all for not holding my hand on this one .
Here is what I tried that seems to work:

Dim i As Integer = arrEditNum.BinarySearch(drg1
(cma.Position, 0))
Dim frm As frmEdit = CType(arrEditfrm(i), frmEdit)
frm.Activate()

So I get the position of the record on the grid from the
currency manager and the ID value (at column 0 on the
grid). But I am using 2 arraylists. One list contains
the IDs and the 2nd arraylist contains the forms. I was
thinking about creating a small class object to contain
both items (ID and frm) so I could search on the ID
property and then invoke/activate the frm property of my
little class object in the arraylist. but back to square
one:

i = arrObj(??).BinarySearch(...)
Dim frm as...(arrObj(??))

Any suggestions how to get the values of my class object
from the arrylist greatly appreciated.

Adda


>-----Original Message-----
>In a Parent mdi form I have a datagrid. I select a

record
>from the grid and then invoke a childmdi form. I add the
>childmdi to an arraylist to keep track of it. If a user
>has selected multiple records from the grid and has
>multiple childmdi forms open and then re-selects a
>previously selected record, I want to activate that
>childmdi form. Suppose the arraylist contains indexes
>0,1,2,3,4 (5 childmdi forms). A user re-selects a child
>at index 2. How can I activate that childform?
>Pseudocode:
>dim arrayfrms As New Arraylist
>....
>arrayfrms(2).Activate
>
>TIA
>Adda
>.
>

 
Reply With Quote
 
Marina
Guest
Posts: n/a
 
      13th Apr 2004
What about using a Hashtable. You can add an ID/form pair. And that way
you can index into the hashtable directly by the ID of the row, to get the
corresponding form, and you don't need to keep multiple lists.

"Adda" <(E-Mail Removed)> wrote in message
news:1bfe301c42180$9377a9c0$(E-Mail Removed)...
> Thank you all for not holding my hand on this one .
> Here is what I tried that seems to work:
>
> Dim i As Integer = arrEditNum.BinarySearch(drg1
> (cma.Position, 0))
> Dim frm As frmEdit = CType(arrEditfrm(i), frmEdit)
> frm.Activate()
>
> So I get the position of the record on the grid from the
> currency manager and the ID value (at column 0 on the
> grid). But I am using 2 arraylists. One list contains
> the IDs and the 2nd arraylist contains the forms. I was
> thinking about creating a small class object to contain
> both items (ID and frm) so I could search on the ID
> property and then invoke/activate the frm property of my
> little class object in the arraylist. but back to square
> one:
>
> i = arrObj(??).BinarySearch(...)
> Dim frm as...(arrObj(??))
>
> Any suggestions how to get the values of my class object
> from the arrylist greatly appreciated.
>
> Adda
>
>
> >-----Original Message-----
> >In a Parent mdi form I have a datagrid. I select a

> record
> >from the grid and then invoke a childmdi form. I add the
> >childmdi to an arraylist to keep track of it. If a user
> >has selected multiple records from the grid and has
> >multiple childmdi forms open and then re-selects a
> >previously selected record, I want to activate that
> >childmdi form. Suppose the arraylist contains indexes
> >0,1,2,3,4 (5 childmdi forms). A user re-selects a child
> >at index 2. How can I activate that childform?
> >Pseudocode:
> >dim arrayfrms As New Arraylist
> >....
> >arrayfrms(2).Activate
> >
> >TIA
> >Adda
> >.
> >



 
Reply With Quote
 
Adda
Guest
Posts: n/a
 
      13th Apr 2004
This seems like a good idea. May I ask how I retrieve the
value part of the hashtable?

Dim myHT as Hashtable
myHT.Add(0, child)
....
myHT.Add(1, child)
....
myHT.Add(2, child)
....

Now to activate child form at position 1

Dim frm As frmChild = CType(myHT(?), frmChild)
frm.Activate

Thanks for your reply.
Adda

>-----Original Message-----
>What about using a Hashtable. You can add an ID/form

pair. And that way
>you can index into the hashtable directly by the ID of

the row, to get the
>corresponding form, and you don't need to keep multiple

lists.
>
>"Adda" <(E-Mail Removed)> wrote in

message
>news:1bfe301c42180$9377a9c0$(E-Mail Removed)...
>> Thank you all for not holding my hand on this one .
>> Here is what I tried that seems to work:
>>
>> Dim i As Integer = arrEditNum.BinarySearch(drg1
>> (cma.Position, 0))
>> Dim frm As frmEdit = CType(arrEditfrm(i), frmEdit)
>> frm.Activate()
>>
>> So I get the position of the record on the grid from the
>> currency manager and the ID value (at column 0 on the
>> grid). But I am using 2 arraylists. One list contains
>> the IDs and the 2nd arraylist contains the forms. I was
>> thinking about creating a small class object to contain
>> both items (ID and frm) so I could search on the ID
>> property and then invoke/activate the frm property of my
>> little class object in the arraylist. but back to

square
>> one:
>>
>> i = arrObj(??).BinarySearch(...)
>> Dim frm as...(arrObj(??))
>>
>> Any suggestions how to get the values of my class object
>> from the arrylist greatly appreciated.
>>
>> Adda
>>
>>
>> >-----Original Message-----
>> >In a Parent mdi form I have a datagrid. I select a

>> record
>> >from the grid and then invoke a childmdi form. I add

the
>> >childmdi to an arraylist to keep track of it. If a

user
>> >has selected multiple records from the grid and has
>> >multiple childmdi forms open and then re-selects a
>> >previously selected record, I want to activate that
>> >childmdi form. Suppose the arraylist contains indexes
>> >0,1,2,3,4 (5 childmdi forms). A user re-selects a

child
>> >at index 2. How can I activate that childform?
>> >Pseudocode:
>> >dim arrayfrms As New Arraylist
>> >....
>> >arrayfrms(2).Activate
>> >
>> >TIA
>> >Adda
>> >.
>> >

>
>
>.
>

 
Reply With Quote
 
Marina
Guest
Posts: n/a
 
      13th Apr 2004
You have the code correct. You would index it by the ID you gave it when you
added the item. So, 0, 1, or 2 in your case, since you added 3 items, with
those keys. Basically, the first parameter to Add it the key, the second is
the value. So whatever the key was that you are looking for.

Hashtable has complete documentation.

"Adda" <(E-Mail Removed)> wrote in message
news:1c45c01c4218a$3a48f5c0$(E-Mail Removed)...
> This seems like a good idea. May I ask how I retrieve the
> value part of the hashtable?
>
> Dim myHT as Hashtable
> myHT.Add(0, child)
> ...
> myHT.Add(1, child)
> ...
> myHT.Add(2, child)
> ...
>
> Now to activate child form at position 1
>
> Dim frm As frmChild = CType(myHT(?), frmChild)
> frm.Activate
>
> Thanks for your reply.
> Adda
>
> >-----Original Message-----
> >What about using a Hashtable. You can add an ID/form

> pair. And that way
> >you can index into the hashtable directly by the ID of

> the row, to get the
> >corresponding form, and you don't need to keep multiple

> lists.
> >
> >"Adda" <(E-Mail Removed)> wrote in

> message
> >news:1bfe301c42180$9377a9c0$(E-Mail Removed)...
> >> Thank you all for not holding my hand on this one .
> >> Here is what I tried that seems to work:
> >>
> >> Dim i As Integer = arrEditNum.BinarySearch(drg1
> >> (cma.Position, 0))
> >> Dim frm As frmEdit = CType(arrEditfrm(i), frmEdit)
> >> frm.Activate()
> >>
> >> So I get the position of the record on the grid from the
> >> currency manager and the ID value (at column 0 on the
> >> grid). But I am using 2 arraylists. One list contains
> >> the IDs and the 2nd arraylist contains the forms. I was
> >> thinking about creating a small class object to contain
> >> both items (ID and frm) so I could search on the ID
> >> property and then invoke/activate the frm property of my
> >> little class object in the arraylist. but back to

> square
> >> one:
> >>
> >> i = arrObj(??).BinarySearch(...)
> >> Dim frm as...(arrObj(??))
> >>
> >> Any suggestions how to get the values of my class object
> >> from the arrylist greatly appreciated.
> >>
> >> Adda
> >>
> >>
> >> >-----Original Message-----
> >> >In a Parent mdi form I have a datagrid. I select a
> >> record
> >> >from the grid and then invoke a childmdi form. I add

> the
> >> >childmdi to an arraylist to keep track of it. If a

> user
> >> >has selected multiple records from the grid and has
> >> >multiple childmdi forms open and then re-selects a
> >> >previously selected record, I want to activate that
> >> >childmdi form. Suppose the arraylist contains indexes
> >> >0,1,2,3,4 (5 childmdi forms). A user re-selects a

> child
> >> >at index 2. How can I activate that childform?
> >> >Pseudocode:
> >> >dim arrayfrms As New Arraylist
> >> >....
> >> >arrayfrms(2).Activate
> >> >
> >> >TIA
> >> >Adda
> >> >.
> >> >

> >
> >
> >.
> >



 
Reply With Quote
 
Adda
Guest
Posts: n/a
 
      13th Apr 2004
This worked perfectly! Many thanks for your help.

Adda


>-----Original Message-----
>You have the code correct. You would index it by the ID

you gave it when you
>added the item. So, 0, 1, or 2 in your case, since you

added 3 items, with
>those keys. Basically, the first parameter to Add it the

key, the second is
>the value. So whatever the key was that you are looking

for.
>
>Hashtable has complete documentation.
>
>"Adda" <(E-Mail Removed)> wrote in

message
>news:1c45c01c4218a$3a48f5c0$(E-Mail Removed)...
>> This seems like a good idea. May I ask how I retrieve

the
>> value part of the hashtable?
>>
>> Dim myHT as Hashtable
>> myHT.Add(0, child)
>> ...
>> myHT.Add(1, child)
>> ...
>> myHT.Add(2, child)
>> ...
>>
>> Now to activate child form at position 1
>>
>> Dim frm As frmChild = CType(myHT(?), frmChild)
>> frm.Activate
>>
>> Thanks for your reply.
>> Adda
>>
>> >-----Original Message-----
>> >What about using a Hashtable. You can add an ID/form

>> pair. And that way
>> >you can index into the hashtable directly by the ID of

>> the row, to get the
>> >corresponding form, and you don't need to keep multiple

>> lists.
>> >
>> >"Adda" <(E-Mail Removed)> wrote in

>> message
>> >news:1bfe301c42180$9377a9c0$(E-Mail Removed)...
>> >> Thank you all for not holding my hand on this one .
>> >> Here is what I tried that seems to work:
>> >>
>> >> Dim i As Integer = arrEditNum.BinarySearch(drg1
>> >> (cma.Position, 0))
>> >> Dim frm As frmEdit = CType(arrEditfrm(i), frmEdit)
>> >> frm.Activate()
>> >>
>> >> So I get the position of the record on the grid from

the
>> >> currency manager and the ID value (at column 0 on the
>> >> grid). But I am using 2 arraylists. One list

contains
>> >> the IDs and the 2nd arraylist contains the forms. I

was
>> >> thinking about creating a small class object to

contain
>> >> both items (ID and frm) so I could search on the ID
>> >> property and then invoke/activate the frm property

of my
>> >> little class object in the arraylist. but back to

>> square
>> >> one:
>> >>
>> >> i = arrObj(??).BinarySearch(...)
>> >> Dim frm as...(arrObj(??))
>> >>
>> >> Any suggestions how to get the values of my class

object
>> >> from the arrylist greatly appreciated.
>> >>
>> >> Adda
>> >>
>> >>
>> >> >-----Original Message-----
>> >> >In a Parent mdi form I have a datagrid. I select a
>> >> record
>> >> >from the grid and then invoke a childmdi form. I

add
>> the
>> >> >childmdi to an arraylist to keep track of it. If a

>> user
>> >> >has selected multiple records from the grid and has
>> >> >multiple childmdi forms open and then re-selects a
>> >> >previously selected record, I want to activate that
>> >> >childmdi form. Suppose the arraylist contains

indexes
>> >> >0,1,2,3,4 (5 childmdi forms). A user re-selects a

>> child
>> >> >at index 2. How can I activate that childform?
>> >> >Pseudocode:
>> >> >dim arrayfrms As New Arraylist
>> >> >....
>> >> >arrayfrms(2).Activate
>> >> >
>> >> >TIA
>> >> >Adda
>> >> >.
>> >> >
>> >
>> >
>> >.
>> >

>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Thread-safety: Change property of items in arraylist versus removingitems from the arraylist Curious Microsoft Dot NET 2 6th Aug 2008 12:36 PM
How to access ArrayList values inside another ArrayList? Pavel Maly Microsoft C# .NET 6 30th Oct 2006 01:46 PM
arraylist inside an arraylist for datagrid, gridview rjl Microsoft C# .NET 4 13th Apr 2006 07:32 PM
ArrayList(ICollection) constructor & overriden ArrayList.AddRange(). Sylvain Microsoft C# .NET 1 4th Jun 2005 01:19 AM
a class inherited from ArrayList, is saved to ViewState, why the type of the object read from ViewSate is not the class, but the parent, ArrayList leal ting Microsoft ASP .NET 0 29th Dec 2003 07:08 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:41 PM.