AddColumn to GRID not working properly

Moderator: Rathinagiri

Post Reply
kjedroska
Posts: 6
Joined: Fri Jan 10, 2025 10:48 pm
DBs Used: DBF

AddColumn to GRID not working properly

Post by kjedroska »

A seemingly simple problem - add a column to the GRID control:

Code: Select all

#include "hmg.ch"

FUNCTION Main
    LOCAL nLiczbaKryt, nLiczbaRol, x, y, cWiersz
    PRIVATE aItems, aNaglowki, aSzerokosci
    SET EXACT ON
    SET DELETED ON
    SET DATE FORMAT "dd.mm.yyyy"

    aItems := {}
    aNaglowki := {}
    aSzerokosci := {}
    nLiczbaKryt := 10
    nLiczbaRol := 10

    FOR x = 1 TO nLiczbaKryt
        AAdd( aNaglowki, ALLTRIM(STR(x)) )
        AAdd( aSzerokosci, 80 )
    NEXT

    FOR y = 1 to nLiczbaRol
        cWiersz := {}
        ASize (cWiersz, nLiczbaKryt)
        FOR x = 1 to nLiczbaKryt
            cWiersz [x] := ALLTRIM (STR (x + y))
        NEXT
        AAdd (aItems, cWiersz)
    NEXT

    Edit_criteria ()

    DoMethod("kryteria", "Activate")
RETURN Nil

PROCEDURE Edit_criteria ()
    DEFINE WINDOW kryteria AT 162 , 472 WIDTH 1137 HEIGHT 744 TITLE "Kryteria" MAIN
        DEFINE GRID Grid_1
            ROW    70
            COL    40
            WIDTH  840
            HEIGHT 420
            ITEMS aItems
            WIDTHS aSzerokosci
            HEADERS aNaglowki
            FONTNAME "Arial"
            FONTSIZE 9
        END GRID

        DEFINE BUTTON Button_11
            ROW    540
            COL    140
            WIDTH  150
            CAPTION "Dodaj kryterium"
            ACTION DodajKryterium()
        END BUTTON
    END WINDOW
RETURN

FUNCTION DodajKryterium()
    LOCAL i, nWiersze, nKolumnyNowe, aNowyWiersz
    LOCAL aNoweNaglowki := {}, aNoweSzer := {}
    LOCAL aNoweItems := {}

    nWiersze := Len(aItems)
    nKolumnyNowe := GetProperty("kryteria", "Grid_1", "ColumnCount") + 1

    FOR i := 1 TO nKolumnyNowe
        AAdd(aNoweNaglowki, ALLTRIM(STR(i)))
        AAdd(aNoweSzer, 80)
    NEXT i

    DoMethod("kryteria", "Grid_1", "AddColumnEx", nKolumnyNowe, "K" + ALLTRIM(STR(nKolumnyNowe)), 80, 0, )
 
    SetProperty("kryteria", "Grid_1", "Headers", aNoweNaglowki)
    SetProperty("kryteria", "Grid_1", "Widths", aNoweSzer)
    DoMethod ("kryteria", "Grid_1", "Refresh")

   FOR i := 1 TO nWiersze
	kryteria.Grid_1.Cell (nKolumnyNowe, i) := "New text"
   NEXT
   
    DoMethod ("kryteria", "Grid_1", "Refresh")
	
RETURN Nil
But the texts in the last column do not appear. Any idea ? Help me please.
User avatar
serge_girard
Posts: 3364
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: AddColumn to GRID not working properly

Post by serge_girard »

Do you K11 column. This is working with HMG3.6

See att.

Serge
Attachments
hmg.png
hmg.png (10.92 KiB) Viewed 523 times
There's nothing you can do that can't be done...
kjedroska
Posts: 6
Joined: Fri Jan 10, 2025 10:48 pm
DBs Used: DBF

Re: AddColumn to GRID not working properly

Post by kjedroska »

I have this column. You are right. But column data are empty. This is that problem - column data are empty
User avatar
serge_girard
Posts: 3364
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: AddColumn to GRID not working properly

Post by serge_girard »

try this:

Code: Select all

   FOR i := 1 TO nWiersze
	   //kryteria.Grid_1.CellEx (nKolumnyNowe, i) := "New text" 
      SetProperty('kryteria', 'Grid_1', 'CellEx', i,nKolumnyNowe , "New text" )  
   NEXT
This fills up the grid

Serge
There's nothing you can do that can't be done...
kjedroska
Posts: 6
Joined: Fri Jan 10, 2025 10:48 pm
DBs Used: DBF

Re: AddColumn to GRID not working properly

Post by kjedroska »

WORKS !!! THX
Post Reply