CLEAR all from msflexgrid

User avatar
sal21
PlatinumLounger
Posts: 4353
Joined: 26 Apr 2010, 17:36

CLEAR all from msflexgrid

Post by sal21 »

I need to clear all from second column (named 1) to the last colomun (named 31), to the and of row, in my case have 52 rows.

note;
The numer of row is dinamic, the coloumn numer are static.
You do not have the required permissions to view the files attached to this post.
Last edited by sal21 on 28 Jun 2021, 16:31, edited 1 time in total.

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: CLEAR all from msflexgrid

Post by HansV »

Perhaps something like

Code: Select all

    Dim i As Long
    With Me,MSFlexGrid1
        For i = 0 To .Rows - 1
            .TextMatrix(i, 1) = ""
        Next i
    End With
I cannot test this myself.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4353
Joined: 26 Apr 2010, 17:36

Re: CLEAR all from msflexgrid

Post by sal21 »

HansV wrote:
28 Jun 2021, 15:57
Perhaps something like

Code: Select all

    Dim i As Long
    With Me,MSFlexGrid1
        For i = 0 To .Rows - 1
            .TextMatrix(i, 1) = ""
        Next i
    End With
I cannot test this myself.
See image attached...
your code clear only the column named "1", and clear also the title column...

I need to clear all column from the named "1" to "GG" to the and rows
Naturally during the clear statement reset the .CellBackColor to the default color (withe in my case)

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: CLEAR all from msflexgrid

Post by HansV »

Code: Select all

    Dim i As Long
    Dim j As Long
    With Me,MSFlexGrid1
        For i = 1 To .Rows - 1
            For j = 1 To .Columns - 1
                .TextMatrix(i, j) = ""
                .CellBackColor = vbWhite
            Next j
        Next i
    End With
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4353
Joined: 26 Apr 2010, 17:36

Re: CLEAR all from msflexgrid

Post by sal21 »

HansV wrote:
28 Jun 2021, 17:57

Code: Select all

    Dim i As Long
    Dim j As Long
    With Me,MSFlexGrid1
        For i = 1 To .Rows - 1
            For j = 1 To .Columns - 1
                .TextMatrix(i, j) = ""
                .CellBackColor = vbWhite
            Next j
        Next i
    End With
work tks.

But i test the icon in cell...
I fill a cell with:
....
.Col = D
.Row = K
Set .CellPicture = Me.ImageList1.ListImages(1).Picturew
...

and based you code instead to clear a text, now i need to clear the icon from cell, how to?

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: CLEAR all from msflexgrid

Post by HansV »

Inside the loop:

Code: Select all

                Set .CellPicture = Nothing
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4353
Joined: 26 Apr 2010, 17:36

Re: CLEAR all from msflexgrid

Post by sal21 »

HansV wrote:
29 Jun 2021, 14:31
Inside the loop:

Code: Select all

                Set .CellPicture = Nothing
:cheers: :cheers: :cheers:
great!