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

Problem with DynamicCurrentCotrol in grids 1

Status
Not open for further replies.

Davin

Programmer
Sep 18, 2000
38
CA
I have a grid that has a column with 3 different textbox controls in it. Depending on the content of the current record depends on which textbox gets focus. The first 2 TextBoxes are bound to data in different tables and the 3rd isn't bound to anything. When the user tries to change data in the column it automatically gives the 3rd textbox focus. This all works great. The only problem is that for some reason the 3rd textbox automatically gets set to readonly and therefore the user can't change any data. I have tried changing the readonly status via the Debugger at run time but VFP automatically changes it back to readonly. Does anyone have any ideas why this is happening?

Other Info:
I am using VFP 6.0. The Columns bound property is set to False. Sparse is set to False. All the data displays properly.
 
Hi!

Interesting functionality combination. Did you tried to set readonly property of column instead of text box?

Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Yes. I checked the read-only status of the Grid, the Columns, and all Textboxes. I got it to work but only when I give the column the same ControlSource as one of the TextBoxes. The first 2 TextBoxes have different ControlSources. Yet it only works when I use the same ControlSource for the column as is in the 2nd TextBox. It doesn't work using the ControlSource of the 1st TextBox.

The other problem I've found, which I beleive is all the same problem, is that the formatting for the TextBoxes is always overridden. For instance, one of my columns has a TextBox which is bound to a Character field from a table other than the table that controls the Grid. When it is first displayed it is fine, but when you actually select the textbox in the grid, it right justifies the text and makes it a maximum of 11 characters long, as if it were a numeric field. The only way that I've found to get around this problem is to give the column a ControlSource which has character data. It seems like you can never have a column without a ControlSource. FoxPro always assigns the next field in the underlyning table to any columns without a ControlSource. It must do it internally since it doen't show up if you inspect the column at run time. Very strange.
 
Hi!

Well, read following considerations from my exeriense on the topic, they might be helpful for you.

1. When adding new controls to column you also require to make them visible. Well, column handles many properties of the controm in it, but some things you still require to do.

2. When grid displays data, it uses column's control source. You're right, when column don't have one, it will take it automatically from the table or just disable column completely. Now, when displaying, it uses the frmatting of the column, not a formatting of the text box. This means that when you have sparse set to .T. and textbox have different appearence than column lines (fint, colors etc.), you will see different appearence for current row and other rows. When Sparse is .F., only textbox's appearence used, but I'm not sure if VFP uses other properties somewhere, for example, in the portion of column that have no rows (back color).

3. When you have DynamicCurrentControl... Well, this is somewhat tricky thing and usually related with refreshing. I tried a grid with column that contains 3 controls - 1 for displaying, 1 for editing and 1 special for filtering. A stuck with a problem that controls refreshed incorrectly - when you expect one control displayed, another displayed instead.

4. Recently I made a nice grid control. All worked ok but the back color of the edit box changed occasionally to the color appropriate to the current row highlighting instead to be white as usual. After some debugging I was ready to report a bug to MS that grid column changes edit box background color to the color currently used for column, that supposed to be a bug. However, last moment I looked into the class used for edit box and found that back color set there... So, check and double check again what happening when you debug. For example, when you switch to debugger, some events already firing, and code of these events may cause control to change in a strange way.

5. Sometimes use of another dynamic* property of column with function that just call refresh method of control could help. This is used for containers in the grid column to refresh value for each row. It seems you require the same for your control if it is not bound to the control source of column.

6. In your case you may try to bind your control to the memory variable. This way grid works correctly, at least I used this in my program for editing control.

Good luck!


Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top