MSHFlexGrid

Hello experts.,
I have a question about substituting text in a MSHFlexGrid with an Image.
I included some code I used to use to convert a boolean expression for Text. It would convert a 1 or -1 to yes or no. this is just an example of what I am trying to do.

Here's my question,  I have a column in my MSHFlexGrid called Checked In. and right now I have Yes or No in text.
What I would like to do is if the word YES appears on that column,  then substitute iw with an image like a check mark or something.
Is that even possible to do?
Thanks very much...
'Dim fmtBooleanData As New StdDataFormat
'fmtBooleanData.Type = fmtBoolean
'fmtBooleanData.TrueValue = "ARRIVED"
'fmtBooleanData.FalseValue = ""
'Set FrmDayView.DataGrid1.Columns(2).DataFormat = fmtBooleanData
'Set FrmDayView.DataGrid1.Columns(7).DataFormat = fmtBooleanData

Open in new window

Stevenj2Asked:
Who is Participating?
 
deicidedxConnect With a Mentor Commented:
to hide the text just clear it from the cell
MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, MSHFlexGrid1.Col)) = ""
to add a loop just use a for next with an incrementing variable
dim i as integer
for i=0 to MSHFlexGrid1.rows-1
    MSHFlexGrid1.Row = i
    MSHFlexGrid1.Col = 8  '<--column 8 called arrived...
    'Make sure you check the value of the current field in the database
    If (MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, MSHFlexGrid1.Col)) = "YES" Then
                        'set the picture if value is "YES"
                        Set MSHFlexGrid1.CellPicture = LoadPicture("C:\Mariner\logo\tick.ico")
    Else
                        'set the picture if value is something else / you can use 'select case' structure to have multiple pictures or if elseif ...
                        Set MSHFlexGrid1.CellPicture = LoadPicture("C:\Mariner\logo\minus.ico")
    End If
    'Clear the text so you get only a picture
    MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, MSHFlexGrid1.Col)) = ""
next i
0
 
deicidedxCommented:
'Set your current cell in which you wish to add the picture
 MSHFlexGrid1.Row =1
 MSHFlexGrid1.Col =1
'Make sure you check the value of the current field in the database
if yourfield.value="1" then
 'set the picture if value is 1
 Set MSHFlexGrid1.CellPicture = LoadPicture("...\...\yourpicture.ico")
else
 'set the picture if value is something else / you can use 'select case' structure to have multiple pictures or if elseif ...
 Set MSHFlexGrid1.CellPicture = LoadPicture("...\...\anotherpicture.ico")
end if
'Move to the next column / same row
 MSHFlexGrid1.Row =1
 MSHFlexGrid1.Col =2
'You can use for / next or other looping stucture to load all the database and set the correct pic for each record...
0
 
Stevenj2Author Commented:
Is this particular with numeris values,  my values in the column are text  either YES blank.
I tried this, but I keep getting object variable errors.
'Set your current cell in which you wish to add the picture
 MSHFlexGrid1.Row =1
 MSHFlexGrid1.Col =11
'Make sure you check the value of the current field in the database
if Arrived.value="YES" then <--- here is where it errors out...
 'set the picture if value is 1
 Set MSHFlexGrid1.CellPicture = LoadPicture("C:\Mariner\logo\tick.ico")
else
 'set the picture if value is something else / you can use 'select case' structure to have multiple pictures or if elseif ...
 Set MSHFlexGrid1.CellPicture = LoadPicture(":C:\Mariner\logo\dash.ico")
end if
'Move to the next column / same row
 MSHFlexGrid1.Row =1
 MSHFlexGrid1.Col =2
'You can use for / next or other looping stucture to load all the database and set the correct pic for each record...
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
deicidedxCommented:
Well the error its correctly triggered because i gave you and example for the if check. There is no such object as arrived.value ..is it ?  I was giving you a hint of where to check the values in the gridview so you have to check it properly.
Maybe you can check this when loading the data into the gridview because there is no point of scanning it again after its loaded.
0
 
Stevenj2Author Commented:
ok,  I got it working ..
I put the code here that is working.
 it puts an icon of a check mark in the column where it says "YES", and  a minus sigh in the column where it is Null.  
when it puts the check mark in the column where it says "YES" it puts the mark right over the "YES"
is there a way to hide the text?  
 I did it manually by changing the column number, but  can you help me add the next loop to the code?
I'm not a seasoned programmer like you guys.
thanks very much...
Dim arrived As Field
'Set your current cell in which you wish to add the picture
MSHFlexGrid1.Row = 1
MSHFlexGrid1.Col = 8  '<--column 8 called arrived...
'Make sure you check the value of the current field in the database
If (MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, MSHFlexGrid1.Col)) = "YES" Then
'set the picture if value is "YES"
Set MSHFlexGrid1.CellPicture = LoadPicture("C:\Mariner\logo\tick.ico")
Else
'set the picture if value is something else / you can use 'select case' structure to have multiple pictures or if elseif ...
Set MSHFlexGrid1.CellPicture = LoadPicture("C:\Mariner\logo\minus.ico")
End If
'Move to the next column / same row
MSHFlexGrid1.Row = 1
MSHFlexGrid1.Col = 2
'You can use for / next or other looping stucture to load all the database and set the correct pic for each record...

Open in new window

0
 
VBClassicGuyCommented:
By the way, for a simplier checkbox, set the cell in the FlexGrid to Wingdings font. Character 253 is a checked checkbox, and I forget the unchecked symbol (you can easily find it). Works great for me!
FlexGrid.Row = r
FlexGrid.Column = c
FlexGrid.CellFontName = "Wingdings"
FlexGrid.CellFontBold = False
FlexGrid.CellFontSize = 14
To set checked:
FlexGrid.TextMatrix(r, c) = Chr$(253)
0
 
Stevenj2Author Commented:
it works perfect.....thank you very much !!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.