Results 1 to 9 of 9

Thread: Listbox Problem??

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Posts
    154

    Listbox Problem??

    Hey Everyone,

    I'm trying to use a listbox as my invoice layout. (so I'm adding new items to the listbox for the invoice)

    is there a way to append text to one line in the listbox? or a different way? or a different control that I should be using?

    So what I mean is...
    Ex.

    I have a label with the column headings.
    "TEM DESCRIPTION PRICE QTY BO AMOUNT

    Then I need to add Items to the listbox as follows..
    ITEM DESCRIPTION PRICE QTY BO AMOUNT

    9999 CD PLAYER 200 1 0 200
    88887 AMPLIFIER 200 1 0 200

    I always need the colums to start at the same position...so if the ITEM #'s are not the same length, DESCRIPTION should still always start at the same spot??

    Thanks for the help in advance!

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I wouldn't use a listbox for this functionality, I'd use a Datagrid and translate your data into a dataset. If you don't want any db backend then just use xml and a schema. OR if you have something against datagrids then I'd use at least a ListView which has columns that you can work with individually.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Posts
    154
    Thanks for the advice!

    I was going to use a datagrid..but when I goto print them invoice I'm thinking that it wouldn't look very good, with all the datagrid lines between all the items!!

    And how would I use a listview to implement this. I'm unfamiliar with them?

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Well no matter what control you use you'll probably want to handle printing seperate from it. I would still use the datagrid but here is code for a listview.

    VB Code:
    1. 'you'll need to add a listview control to the form where you put this code
    2.         'setup listview
    3.         'this part can also be done at designtime in the IDE
    4.         ListView1.Columns.Add("Item", 50, HorizontalAlignment.Center)
    5.         ListView1.Columns.Add("Description", 125, HorizontalAlignment.Left)
    6.         ListView1.Columns.Add("Price", 80, HorizontalAlignment.Right)
    7.         ListView1.Columns.Add("Quantity", 40, HorizontalAlignment.Center)
    8.         ListView1.Columns.Add("BO", 40, HorizontalAlignment.Center)
    9.         ListView1.Columns.Add("Amount", 80, HorizontalAlignment.Right)
    10.         ListView1.View = View.Details
    11.  
    12.         'now add data
    13.         'start with first column
    14.         Dim lvi As New ListViewItem("9999")
    15.         'add other columns
    16.         lvi.SubItems.Add("CD Player")
    17.         lvi.SubItems.Add("$200.00")
    18.         lvi.SubItems.Add("1")
    19.         lvi.SubItems.Add("0")
    20.         lvi.SubItems.Add("$200.00")
    21.         'now add it to the listview
    22.         ListView1.Items.Add(lvi)
    23.         'second item (could be done in a loop)
    24.         lvi = New ListViewItem("88887")
    25.         lvi.SubItems.Add("Amplifier")
    26.         lvi.SubItems.Add("$200.00")
    27.         lvi.SubItems.Add("1")
    28.         lvi.SubItems.Add("0")
    29.         lvi.SubItems.Add("$200.00")
    30.         ListView1.Items.Add(lvi)
    31.  
    32.         'change a something in existing data
    33.         'the qty and amount in the second line
    34.         ListView1.Items(1).SubItems(3).Text = "2"
    35.         ListView1.Items(1).SubItems(5).Text = "$400.00"

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Posts
    154
    Thanks for the help...but I Have a couple more questions?

    Is there a way to list the data like in detail view but without the column headers? Or can I change the backcolor of them?

    What do you mean I could do this at design time with IDE? it's the IDE I'm asking about?

    Is there a way with the listview to make it so if you add more items than the size of the listview it will autosize or something like that?

    And lastly....what would be the benifit of using a datagrid instead of the listview?

    Thanks again

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    "Is there a way to list the data like in detail view but without the column headers?"

    Yes you can set the HeaderStyle to None.

    "Or can I change the backcolor of them?"

    Not that I know of but see above.

    "What do you mean I could do this at design time with IDE? it's the IDE I'm asking about?"

    Instead of through code you can do the setup part by changing the properties of the listview at designtime.

    "Is there a way with the listview to make it so if you add more items than the size of the listview it will autosize or something like that?"

    No there is not automatic resize you'll have to write your own. You can change the size but it doesn't autosize.

    "And lastly....what would be the benifit of using a datagrid instead of the listview?"

    Lots, mainly instead of filling each row and having each item be string representives of your data you can just bind the grid to the data itself and set formatting rules. If you aren't using some sort of datasource currently then you probably should or at least be using some class object (which can also be bound to the grid). The datagrid is just much more flexible in my opinion. You should learn more about it, it'll come in handy someday.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Posts
    154
    One last question...

    you know how with a datagrid on the very left hand side...it has like a column index or something ( an xtra colum for clicking or something....the very left one anyway..)

    can you make that so it is not displayed?

    cause if you can...then I think I'm going to try the datagrid instead. I was just looking at it.

    I've used it before....actually in my current program I have about 5 different datagrids already.

  8. #8
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Set the RowHeaderVisible property of datagrid to False

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Posts
    154
    hey there,

    I took your advice and used the datagrid..It's going to work out quite nice I think.....But how can I make it so it inserts all the items in the grid back to the database??

    This is the main issue...I'm also going to post this big problem I'm having and c if you can help me with it too?

    Thanks..

    ****************************************************
    SQL DB Design??
    hey everyone...

    I'm kind of stuck on what I need/should do to do what I need my program to do.

    I have a table called CUSTOMERS--It contains all the Customers
    I have a table called PARTS-- It contains all the Parts
    I have a table called INVOICES-- It contains all the Invoices

    None of the tables are linked.

    I've attached some printscreens of part of my program layout...


    FORM1 is the first form to load.....you click on the customer you want and then it opens FORM2.

    When FORM2 loads it, selects all Invoices that = the specific customer.

    You can then click the NEW INVOICE button, which opens FORM3.
    The you can click the "Click Here to add new part..." label, and that opens FORM4.

    Then you just click the part you want and it then adds the part to FORM3...which you can see what it looks like with FORM5.

    So I have a couple concerns.....

    1. If I was to delete a PART from the parts table....and 1 of my invoices contained that part...then when I went back to edit the invoice..the part would not display... I want to be able to click on one of the Invoices from FORM2, and then edit the invoice if needed?

    2. I need to be able to calculate Backorders, if the there is no stock of that part. I also need to be able to calculate Amount depending on stock and the price of the part??

    Any help is appreciated.

    Thanks in advance!!
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width