|
-
Feb 7th, 2007, 06:58 AM
#1
Thread Starter
Fanatic Member
VB2005 Save coordinates in array?
Hello,
I have a form called frmMainForm. On that form I have a datagridview containing several products.
When I click on a rowheader of the datagridview another form openes called frmCuts.
On the frmCuts you can add coordinates for a product.
For example (2, 2, 67, 103).
How can I assign these coordinates to the row in the datagridview?
I am not allowed to save the coordinates in the database.
How do I save them for the duration that the program is open?
-
Feb 7th, 2007, 07:15 AM
#2
Re: VB2005 Save coordinates in array?
"The dark side clouds everything. Impossible to see the future is."
-
Feb 7th, 2007, 07:16 AM
#3
Thread Starter
Fanatic Member
Re: VB2005 Save coordinates in array?
 Originally Posted by Asgorath
or inside an arraylist
Could you please give me a little example please?
-
Feb 7th, 2007, 07:20 AM
#4
Re: VB2005 Save coordinates in array?
Just call the .Add(value) method
"The dark side clouds everything. Impossible to see the future is."
-
Feb 7th, 2007, 07:27 AM
#5
Thread Starter
Fanatic Member
Re: VB2005 Save coordinates in array?
I do not understand...sorry
-
Feb 7th, 2007, 07:31 AM
#6
Re: VB2005 Save coordinates in array?
VB Code:
Dim arr as new ArrayList
arr.Add(2)
arr.Add(2)
arr.Add(67)
arr.Add(103)
"The dark side clouds everything. Impossible to see the future is."
-
Feb 7th, 2007, 07:34 AM
#7
Thread Starter
Fanatic Member
Re: VB2005 Save coordinates in array?
But my arry will have to look lik
ProductID Coordinates
2 (1, 3, 66, 77)
5 (44, 66, 89, 8)
And so on
-
Feb 7th, 2007, 07:43 AM
#8
Re: VB2005 Save coordinates in array?
Define a class for your product. Create a BindingList and add instances of your class to it. Bind that list to your grid. When you open the dialogue pass one of the class instances to it. When you make changes to the object in the dialogue they will be reflected in the grid because the same object is still bound to the grid.
-
Feb 7th, 2007, 07:46 AM
#9
Thread Starter
Fanatic Member
Re: VB2005 Save coordinates in array?
Thank you very much for the reply.
Could youplease provide me with an example.
Because I dont get it..
-
Feb 7th, 2007, 08:04 AM
#10
Re: VB2005 Save coordinates in array?
Read my post one sentence at a time.
Define a class for your product.
Do you know how to define a class? What members would your class need?
Create a BindingList and add instances of your class to it.
Have you used a BindingList before? Probably not, but it is just a collection with some special behaviour that makes it good for data binding. Look it up on MSDN and read about it.
Bind that list to your grid.
You already know how to bind to a grid because you've done it before with a DataTable I'll wager. Etc., etc. Just because you haven't done that whole thing before doesn't mean you can't do parts of it. Someone may not be able to drive but that doesn't mena someone has to show them how to turn an ignition key. I believe that you are capable of implementing at least part of what I have suggested. The fact that you posted three minutes after me indicates that you didn't ponder the possibility too long.
-
Feb 7th, 2007, 08:20 AM
#11
Thread Starter
Fanatic Member
Re: VB2005 Save coordinates in array?
Yes I know what a class is but not how to use it in my case.
I read about the bindinglist but I just dont get it.
And I know how to bind data.
I just dont see it.
-
Feb 8th, 2007, 07:21 AM
#12
Thread Starter
Fanatic Member
Re: VB2005 Save coordinates in array?
Can I reach my purpose using a collection?
I tried this:
VB Code:
Dim intNumberOfRows As Integer
Dim intRow As Integer = 0
Dim colData As New Collection
Dim coordinates As String
Private Sub frmMainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
intNumberOfRows = WoodsheetsTableAdapter.Fill(Me.WoodshopDataSet.woodsheets)
Dim row As DataRow = Nothing
Dim i As Integer
For i = 0 To intNumberOfRows
row = WoodshopDataSet.woodsheets.Rows(0)
colData.Add(coordinates, row.Item(1))
Next i
But I get an error message saying something about "dublicate keys.."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|