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?
Re: VB2005 Save coordinates in array?
Re: VB2005 Save coordinates in array?
Quote:
Originally Posted by Asgorath
or inside an arraylist
Could you please give me a little example please?
Re: VB2005 Save coordinates in array?
Just call the .Add(value) method
Re: VB2005 Save coordinates in array?
I do not understand...sorry
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)
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
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.
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..
Re: VB2005 Save coordinates in array?
Read my post one sentence at a time.
Quote:
Define a class for your product.
Do you know how to define a class? What members would your class need?
Quote:
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.
Quote:
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.
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.
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.."