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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grid with editable Yes/No field 1

Status
Not open for further replies.

markros

Programmer
May 21, 2007
3,150
US
Hi,

I'd like to be able to have a column in a grid bound to a logican field that would display "Yes or No". I also would like to be able to edit this field.

If it would be only for display, it would not be a problem.

Any ideas of how to make this field editable?

Thanks.
 
Why the checkbox didn't work for you?

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
One possibility would be to place two labels in the column, in place of the textbox that's normally there. Set the caption of one of the labels to Yes and the other to No.

Then set the column's DynamicCurrentControl to point to whichever of the two labels you want to display, according to some condition in your data.

In the column's double-click, toggle the condition and refresh the grid.

So, if the labels are called lblYes and lblNo, and your table contains a field called Discount, and you want to show Yes when Discount is true:

Code:
* In the grid's Init
THIS.Column1.DynamicCurrentControl = ;
  "IIF(Discount, 'lblYes', 'lblNo')"


* In the DblClick:
Discount = NOT Discount
this.Refresh

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
You could also set the controlsource of the column's textbox to the IIF and in the click or doubleclick change the logical field:

Code:
grid1.column1.text1.controlsource = "(iif(discount,'YES','NO')"

And in the click or dblclick do
Code:
replace next 1 discount with not discount in (this.parent.parent.recordsource)
this.parent.parent.refresh()

Make the textbox readonly or even disabled, if you want no blinking cursor in it.

Bye, Olaf.
 
Put a checkbox in the column, set its Style property to "1-Graphical" and set the Picture and DownPicture properties to bitmaps of "Yes" and "No" respectively.

Or are you wanting the user to be able to type "Y...E...S" into the cell?

Geoff Franklin
 
I like Olaf's suggestion as the simplest of all - so I'll try it.
 
Markros,

I agree that Olaf's idea is simple, and it should do just what you want. But if you have time, it would be worth trying the other suggestions as well.

Either way, let us know how it works out.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Simplest??????????
It is much more simple than a checkbox control in the column?
And HOW your users will know that if they CLICK or DoubleClick will change the value?


Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Basically, I agree that checkbox is a good interface too. The client says it's up to me, but in his original sketch he showed Yes/No and X in the selected field. The application currently uses both styles (X and checkbox) already.

I went ahead with Olaf's suggestion, but unfortunately I can not test the form standalone and I have to plug it in the application (the other form) and this will require some time, since I also need to create two extra tables, etc.

So, hopefully I'll finish this at the end of the day and would be able to test. I would not be able to test DynamicCurrentControl (seems an overkill to me) and the Graphical Checkbox ideas.
 
Well, I don't think the graphical checkbox is an overkill. It creates a good looking option, the button look also makes it intuitive, that it's clickable.

I wonder why you talk about additional tables. You'll have a boolean field, don't you? Or did you design a table with a C(1) or C(3) field? for Y/N or Yes/No?

In regard to what is intuitive or not, this reminds me of a prediction from decades ago, which kind of became true: "Computers will become as easy to use as phones." Well, what's true is, that today phones really ARE as hard to use as computers.

Bye, Olaf.
 
For the form where I want this functionality I need to create two extra tables, then from another form I need to program the functionality to call this new form...

And I was busy with lots of other stuff today, so I'm getting back to this only now.
 
I've implemented Olaf's idea, worked great.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top