Announcement

Collapse
No announcement yet.

ListView Example with PB9

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ListView Example with PB9

    Does anyone have a small demo of filling a ListView with PB9?
    Just want to fill some rows and columns with text.
    The world is full of apathy, but who cares?

  • #2
    Like a normal Listview? (well there could be several cases)

    Or

    More like a Excel Worksheet sort of thing???
    Engineer's Motto: If it aint broke take it apart and fix it

    "If at 1st you don't succeed... call it version 1.0"

    "Half of Programming is coding"....."The other 90% is DEBUGGING"

    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

    Comment


    • #3
      Like a Grid:
      Code:
       
      [FONT=courier new][FONT=courrier new][FONT=courier new]ROWID    FIRST NAME   LAST NAME[/FONT][/FONT][/FONT]
      [FONT=courier new][FONT=courrier new]-----    ----------   ---------[/FONT]
      [FONT=courier new][FONT=courier new]1        Joan         Crawford [/FONT]
      [FONT=courier new]2        Marilyn      Monroe[/FONT]
      [FONT=courier new]3        Homer        Simpson[/FONT]
      [/FONT][/FONT]
      Last edited by Mike Doty; 8 Oct 2008, 07:05 AM. Reason: Fixed font
      The world is full of apathy, but who cares?

      Comment


      • #4
        Interesting, no responses.
        LISTVIEW SET TEXT hDlg, id&, row&, col&, StrExpr
        The text, if any, for the specified data item is replaced by the new text in StrExpr. You must keep in mind that this statement does not create a new item (horizontal row), but changes existing text, if any, to new text. To create a new data item (horizontal row), use LISTVIEW INSERT ITEM instead. The values of row&/col& specify the position of the data item (1=first, 2=second, etc.).
        So, the first column use: LISTVIEW INSERT ITEM
        and for the other columns LISTVEW SET TEXT?
        The world is full of apathy, but who cares?

        Comment


        • #5
          >Interesting, no responses.

          From 5.34 PM to 9.27 AM? (US CDT). Gee, I'm shocked. I would have tried it but my dinnertime and sleep time kind of interfered.

          I guess the 'expectation game' applies here as well as in the Presidential debates....
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            I've got it working. That was yesterday.
            I'm surprised there is no examples.
            The world is full of apathy, but who cares?

            Comment


            • #7
              Originally posted by Mike Doty View Post
              I've got it working. That was yesterday.
              I'm surprised there is no examples.
              do you mean recoding a List View using classes, or a List View COM object, or what?

              Comment


              • #8
                1) This works,but need to speed it up. Functions starting with sl are from SQLitening.
                2) Need to correctly calculate column widths.
                Code:
                FUNCTION DisplayRecordSet(hDlg AS DWORD) AS DWORD
                  LOCAL row AS DWORD, col AS LONG, ColumnCount AS LONG
                  ColumnCount = slGetColumnCount   'SQLitening
                  IF ColumnCount THEN
                    MOUSEPTR 11
                    LISTVIEW RESET hDLG, %IDC_LISTVIEW
                    FOR col = 1 TO ColumnCount   'Insert columns with column names
                      LISTVIEW INSERT COLUMN hDlg, %IDC_LISTVIEW,col,slGetColumnName(col),100,0
                    NEXT
                  ELSE
                    ? "No columns"
                    EXIT FUNCTION
                  END IF
                  DO WHILE slGetRow
                    INCR row
                    LISTVIEW INSERT ITEM hDlg, %IDC_LISTVIEW,row, 0 , slF(1) 'Insert row, 0=no image
                    FOR col = 2 TO ColumnCount                               'add text into columns
                      LISTVIEW SET TEXT hdlg, %IDC_LISTVIEW, row, col,slF(col)
                      IF row =40 OR (row MOD 500) = 0 THEN
                         CONTROL SET TEXT hDlg, %IDC_LABEL1, "Records for far" + STR$(row)
                         DIALOG DOEVENTS:SLEEP 10
                      END IF
                    NEXT
                  LOOP
                  DIALOG DOEVENTS
                  MOUSEPTR 1
                  FUNCTION = row
                END FUNCTION
                Last edited by Mike Doty; 8 Oct 2008, 02:49 PM.
                The world is full of apathy, but who cares?

                Comment


                • #9
                  I've got it working. That was yesterday.
                  I'm surprised there is no examples
                  If you had any sense of duty or honor, we'd all have an example because you'd post your example in the Source Code Forum (with a searchable title eg "PB/Win 9 DDT LISTVIEW Demo") for all to find and use.

                  MCM
                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                  • #10
                    There is a filefind routine that has a listview which I found in another thread. I would post, but I'm not done. You guys are the listview experts. I'm not done.
                    Why didn't you?
                    Last edited by Mike Doty; 8 Oct 2008, 02:57 PM.
                    The world is full of apathy, but who cares?

                    Comment


                    • #11
                      Oh I see. DDT LISTVIEW. If you have access to working SDK listview code, why not use that, the API won't go away!

                      You will be using LISTVIEW FIT HEADER or LISTVIEW FIT CONTENT to fit the column to the data or column headings, or when you want to use a minimum width of the column heading and a maximum fixed width, you could measure the width of the text in the column header by using LISTVIEW SET HEADER then LISTVIEW GET COLUMN to get the minimum width, then LISTVIEW SET COLUMN to set the width.

                      Comment


                      • #12
                        I *meant* when you are done.

                        Be sure to include examples of Mr. Holbrook's suggestions re LISTVIEW FIT something.

                        >Why didn't you?
                        I have already posted about five different listview demos.

                        It's your turn.

                        MCM
                        Michael Mattias
                        Tal Systems (retired)
                        Port Washington WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                        • #13
                          Originally posted by Mike Doty View Post
                          Does anyone have a small demo of filling a ListView with PB9?
                          Just want to fill some rows and columns with text.
                          =================================
                          I do not know why I am inside this message, I wanted just to post the reply. There is something wrong with login in to this forum.
                          As the reply:
                          Have you checked the thread :

                          http://www.powerbasic.com/support/pb...ad.php?t=38371

                          posted here on 2 October 2008?

                          Regards,
                          M.N

                          Comment


                          • #14
                            This works,but need to speed it up.
                            Code:
                            DO WHILE slGetRow
                            ....
                                IF row =40 OR (row MOD 500) = 0 THEN
                            How many rows do you have?

                            Code:
                            CONTROL SET TEXT hDlg, %IDC_LABEL1, "Records for far" + STR$(row)
                            DIALOG DOEVENTS:SLEEP 10
                            You are doing these for each column when the row=40 or row MOD 500= 0; but row number ain't changing here!. I think I'd do this only after all columns for target row were inserted.

                            Today's School of Hard Knocks Tip: You can (noticeably) speed up the loading of listview controls by setting the number of rows using the API function ListView_SetItemCount before you start actual loading.
                            Last edited by Michael Mattias; 9 Oct 2008, 07:06 AM.
                            Michael Mattias
                            Tal Systems (retired)
                            Port Washington WI USA
                            [email protected]
                            http://www.talsystems.com

                            Comment

                            Working...
                            X