[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

MSHFlexGrid

Posted on 2009-12-28
7
Medium Priority
?
1,204 Views
Last Modified: 2013-12-20
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

0
Comment
Question by:Stevenj2
  • 3
  • 3
7 Comments
 
LVL 4

Expert Comment

by:deicidedx
ID: 26136886
'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
 

Author Comment

by:Stevenj2
ID: 26142671
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
 
LVL 4

Expert Comment

by:deicidedx
ID: 26143177
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Stevenj2
ID: 26149716
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
 
LVL 4

Accepted Solution

by:
deicidedx earned 2000 total points
ID: 26149867
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
 
LVL 14

Expert Comment

by:VBClassicGuy
ID: 26150893
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
 

Author Comment

by:Stevenj2
ID: 26152624
it works perfect.....thank you very much !!!!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month20 days, 12 hours left to enroll

865 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question