Solved

help using dataviewgrid for selected items on form

Posted on 2010-09-22
8
258 Views
Last Modified: 2012-05-10
Hi,
   I am creating an EPOS system and I have a series of buttons on my form.  When someone clicks a button I want the following to be added under columns on the dataviewgrid1 component:

Description
Quantity
Price
Vat

Then when another button is clicked, on another line the new item etc

How can I do this?

Thanks
0
Comment
Question by:damianb123
[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
  • 5
  • 3
8 Comments
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33733594
Hi.
You mean DatagridView?
0
 

Author Comment

by:damianb123
ID: 33733611
Yup - sorry!!!
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33733692
try this in form LoadEvent...(if i understand well)
 Dim txt1, txt2, txt3, txt4 As New DataGridViewTextBoxColumn
        txt1.Name = "Description"
        txt2.Name = "Quantity"
        txt3.Name = "Price"
        txt4.Name = "Vat"

        Me.DataGridView1.Columns.Insert(0, txt1)
        Me.DataGridView1.Columns.Insert(1, txt2)
        Me.DataGridView1.Columns.Insert(2, txt3)
        Me.DataGridView1.Columns.Insert(3, txt4)

Open in new window

0
Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

 

Author Comment

by:damianb123
ID: 33733767
jtoutou,
    that works great, thanks.  Now what i need to do is have the system so that when a button is clicked the details are added to the form.....  This is the code I used on a previous project, however the description was only piped to a txt box and not multiple columns.  
Multiple buttons need to be capable of adding multiple rows.....

Thanks
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33734462
Sorry for the delay .....ok we have the column ....now for the cells....
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim dgvRow As New DataGridViewRow
        Dim dgvCell As DataGridViewCell

        dgvCell = New DataGridViewTextBoxCell()
        dgvCell.Value = "SomeDescription"
        dgvRow.Cells.Add(dgvCell)

        dgvCell = New DataGridViewTextBoxCell()
        dgvCell.Value = "SomeQuantity"
        dgvRow.Cells.Add(dgvCell)

        dgvCell = New DataGridViewTextBoxCell()
        dgvCell.Value = "SomePrice"
        dgvRow.Cells.Add(dgvCell)

        dgvCell = New DataGridViewTextBoxCell()
        dgvCell.Value = "SomeVat"
        dgvRow.Cells.Add(dgvCell)

        DataGridView1.Rows.Add(dgvRow)

    End Sub

Open in new window

0
 
LVL 18

Accepted Solution

by:
John (Yiannis) Toutountzoglou earned 500 total points
ID: 33734919
And just a note:Rows cannot be added programatically to the datagridview's collection when control is databound!!!!!we are talking now about custom Datagridview.....


in this case lets say we have to buttons....just do the same job with defferent text...
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim dgvRow As New DataGridViewRow
        Dim dgvCell As DataGridViewCell

        dgvCell = New DataGridViewTextBoxCell()
        dgvCell.Value = "SomeDescription"
        dgvRow.Cells.Add(dgvCell)

        dgvCell = New DataGridViewTextBoxCell()
        dgvCell.Value = "SomeQuantity"
        dgvRow.Cells.Add(dgvCell)

        dgvCell = New DataGridViewTextBoxCell()
        dgvCell.Value = "SomePrice"
        dgvRow.Cells.Add(dgvCell)

        dgvCell = New DataGridViewTextBoxCell()
        dgvCell.Value = "SomeVat"
        dgvRow.Cells.Add(dgvCell)

      
        Me.DataGridView1.Rows.Add(dgvRow)

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim dgvRow As New DataGridViewRow
        Dim dgvCell As DataGridViewCell

        dgvCell = New DataGridViewTextBoxCell()
        dgvCell.Value = "SomeDescription2"
        dgvRow.Cells.Add(dgvCell)

        dgvCell = New DataGridViewTextBoxCell()
        dgvCell.Value = "SomeQuantity2"
        dgvRow.Cells.Add(dgvCell)

        dgvCell = New DataGridViewTextBoxCell()
        dgvCell.Value = "SomePrice2"
        dgvRow.Cells.Add(dgvCell)

        dgvCell = New DataGridViewTextBoxCell()
        dgvCell.Value = "SomeVat2"
        dgvRow.Cells.Add(dgvCell)


        Me.DataGridView1.Rows.Add(dgvRow)
    End Sub

Open in new window

0
 

Author Closing Comment

by:damianb123
ID: 33781408
This worked perfectly, thanks very much for all your help!
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33782052
very welcome.....very glad helping you
0

Featured Post

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

717 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