Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grid as a Picklist

Status
Not open for further replies.

bharatindia

Instructor
Dec 14, 2011
6
0
0
IN
Hi Experts,

I have a grid with one column called agent_name i am using it as picklist inside a grid in 2nd column for
data entry when i type a letter say A is display in the grid all names start with 'A' etc. but now what i
want to acheive is that instead of displaying records which start with "A" it display all records without
filtering but display records start with "A" in fontbold=.t. and foreclor=(some color.


i try to acheive the above with

THISFORM.CONT_VOUCHER.GRID_LEDG_LIST.SetAll("dynamicforecolor", ;
"IIF( like(YOURWORD,lower(LEDGER)) , RGB(255,0,0), RGB(0,0,0))", "Column")

but it gives some error.

Please help to acheive it.

Thanks & Regards
 
Could by related to the scope of variables, if YOURWORD is the name of a local variable.

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
As mentioned earlier, what is the error ?

Your statement syntax looks good.
You may have type error 'YOURWORD' and 'LEDGER'. If user is typing 'YOURWORD', you may need to append '*' after trimming.


 
Hi

The grid is failing because it can't seem to cope with your IIF() expression. Syntactically it seems to be ok, but grids are beasts of a single mind so
they are better treated with a UDF that achieves the same thing. You could then debug your function quite easily. I would check that the values for
YOURWORD and LEDGER are available at runtime:



Code:
THISFORM.CONT_VOUCHER.GRID_LEDG_LIST.SetAll("dynamicforecolor", "UDFColourFunct()", "Column")

function UDFColourFunct
  private m.Colour
  m.Colour = RGB(0,0,0)
  if Type("YourWord") = "C" .and. Type("Ledger") = "C"
    if like(lower(trim(YOURWORD+"*")),lower(LEDGER))
      m.Colour = RGB(255,0,0)
    endif
  endif
Return(M.Colour)



Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
Oops
Bracket in the wrong place

Code:
if like(lower(trim(YOURWORD)+"*"),lower(LEDGER))

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
As well as telling us what the error is, it would also help if you could let us know where you have placed your code. Is it in the Init of the grid? Or the Init of the form? Or somewhere else?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I bet on Vilhelm-Ion. It explains the error, as the IIF expression is correct, but can't be evaluated without the variables existing in the context of the Grid itself.

You can think of the dynamicxyz (forecolor/backcolor/bold/italic etc) properties of grid columns as single line methods, that only have place for a single line of code resulting in a value of the right type, in your case a color. Variables existing while you set the IIF don't help, as the GRID does execute the dynamic property later, when your code setting the property is already done and its variables are already released.

In a simple IIF expression you can addrress fields of the grid rowsource and controls of the forms, but not variables. Griff has a good idea to write a grid or form mtetod and call that. In that method you can write verbose code and read out user input from a form textbox etc. Things you can't easily push all into a single IIF, so this is the best way to solve the problem. If you have an error in your method code then, this will show up normal and is easier to debug and fix than an error in an expression set into the dynamicforecolor property.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top