vb.net ListView How it works?

Here i will explain how the list view works in VB.Net

Let just create an situation where you want to create an list view.

Example:- Let just say you are building an Point Of Sale VB.NET application.

As soon as you scan an item you need to fetch an item from database and append it into an listview.

How to create a Listview

Just simply drag the Listview from toolbar. Just Make sure you set the View property to Details

NOTE:- ** In most case this the problem that people forget it.

listview-image

 

Change the name property of listview to ItemsListView

 

Next we need to add 4 columns into our Listview.

How to add Columns into ListView

 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        ItemsListView.Columns.Add("ID", 40)
        ItemsListView.Columns.Add("Name", 250)
        ItemsListView.Columns.Add("Qty", 70)
        ItemsListView.Columns.Add("Price", 100)

        Me.Show()
        Application.DoEvents()
        barcode.Focus()

    End Sub

First argument is the “LABEL” Second argument is the width of an Column.

If you want to changed the size of an listview columns just changed the value above

So if you execute the command it would looks like this

listview-image

 

Next When someone scan the item we need to fetch and append the value of an item into a list view

How to add Subitems into an listview

 

 Item = ItemsListView.Items.Add("ID_CHANGE_YOUR_ITEM_ID")
  With Item
       .SubItems.Add("ITEM_NAME_CHANGE_YOUR_ITEM_NAME")
       .SubItems.Add("QTY_CHANGE_YOUR_QTY")
       .SubItems.Add("PRICE_CHANGE_YOUR_PRICE")
 End With

 

One thing that you might need to do is Just change the qty of an item so in other words you want to changed the Listview Item text

How to changed Existing ListView Item Text

For Each myItem As ListViewItem In ItemsListView.Items()
     If myItem.Text = reader(0) Then
         'above line just an condition to check if it's an existing item... You can changed it based on your requirement.    
         ItemsListView.Items(myItem.Index).SubItems(0).Text = "MY_NEW_ID_VALUE"
         ItemsListView.Items(myItem.Index).SubItems(1).Text = "MY_NEW_ITEM_NAME_VALUE"
         ItemsListView.Items(myItem.Index).SubItems(2).Text = "MY_NEW_QTY_VALUE"
         ItemsListView.Items(myItem.Index).SubItems(3).Text = "MY_NEW_PRICE_VALUE"
    End If 
Next

 

 

listview-image

Next Step When someone finished paying to you in that case for your next customer you need to clear all the sub items into a list view

How to Clear Listview Subitems

ItemsListView.Items.Clear()
barcode.focus()

If anyone got any problem with ListView please comment it and i hope all of us try to solve it asap.

listview-image

August 20th, 2013 by kdecom

VB . NET tips and tricks

I am very much beginner for VB .Net application. So you might not find a very advanced level tips here but some basics which helps everyone in everyday development of Visual Basic . Net development.

Database connection string with windows authentication don’t works.

when i was new with VB .net i was trying to setup a temp database with temp tables and trying to display a record using a DataGrid view but for some reason it wasn’t working.

In my case it was something to do VS studio 2013 preview edition. Then i did download VS 2012 and its starts working. So there is some bug in VS 2013 editor.

 

 How to focus a textbox in vb.net

Here is a small code snippet for VB.net Developer to focus a textbox in form load.

 

Me.Show()
Application.DoEvents()
barcode.Focus()

 

how to force a text to 2 decimal places in vb .net

Format(Double.Parse(subtotal.Text), "0.00")
First it convert text to double which gets formatted to 2 decimal places. 
Output example:-

2 => 2.00
1.1234 => 1.12

Form KeyDown event is not firing or not working?

I got a simple solution just go to form and make sure keyPreview proporty of that form set to true.

KeyPreview = true

 

August 15th, 2013 by kdecom

Free email for my domain name

First thing that i was thinking once i bought my domain name.

How do i get free email for my domain name?

First name comes up  in my mind was google then i did some research and i findout that google stops their free email service to paid for everyone. After a while i was seaching for a good free Email Service with customized with your own domain name what i did found is:- With Microsoft latest outlook.com you can setup own email adress with unlimited space and spam filter and all service that normally all Email Server provides. you can get it free. 

After that i did start looking for how to setup your domain name to use Outlook finally i did it and its working so nicely for me.

So here is the solution for anyone who is looking to setup free email service for their domain name and they can start using it for free email of their own domain name.

Here are the few steps for you to setup free email service for personal domain name:-

This link has a quick overview on how Windows outlook admin screen works: Windows Live.

microsoft-free-email-service-setup-admin-screen

 

Step2:- click on get Started

type your domain name:- example.com and in my case it was foodmart.co.nz

microsoft-free-email-service-setup-admin-screen

 

Step3:- as soon as you click continue it asked you to verify domain name with adding an mx record for your domain name.

If you are not sure how to setup mx record for your domain name then click here.

Usually it is different for different hosting company.

 

Once domain name is been verified then click refresh and then onwards you can click Add button to add Email address.

How to check your email?

Sign in at http://mail.live.com with your new e-mail address, e.g. info@foodmart.co.nz

 

August 11th, 2013 by kdecom

Display Form using one line in View file – Zend Framework 2

How to Disaply a Form in View file using a one line render function as we used to do in ZF 1.12.

This is a very small one line tips for a zend framework2 developer how to renfer a form using a form view helper.

$this->form->prepare();
$this->form()->render($this->form);
June 13th, 2013 by kdecom