Solved

Grid text entry

Posted on 2002-05-07
5
321 Views
Last Modified: 2012-06-27
I have an MSFlexgrid which is not only used to display text from a "spreadsheet" but should also allow the user to edit a cell.

The .Text property lets me access the data, but there's no real interface to get data in.

I tried overlaying a textbox, but the cell size is too small and the textbox won't resize that small without changing the font.  It also doesn't easily scroll when the grid scrolls.

I've tried using the KeyPress event, but it leaves the user without a cursor.

Has anyone else dealt with data entry into a flexgrid?  How have you handled these issues?
0
Comment
Question by:rspahitz
5 Comments
 
LVL 7

Expert Comment

by:Joe_Griffith
ID: 6994886
I have been successful using a text box on top of the cell to be edited.  It's not easy however, and to really make it work smoothly you have to write a fair amout of pretty complicated code.

I've never had any trouble with the cell size and the size of the text box.  Make sure you turn off the text box's border.  It should then easily fit in the cell.

Scrolling is the major problem and requires repositioning the text box with every movement.  My application only requires vertical scrolling and I have been able to make it work fairly well.

There are other grids available that avoid the whole problem but they have their own set of problems.  The reason I stayed with a kludge of the flex grid was to have complete control of the tab and shift tab key strokes.
0
 
LVL 18

Expert Comment

by:mdougan
ID: 6994893
Well, the real answer is to pony-up the cash and buy the full version of the flexgrid from VideoSoft (now called ComponentOne at www.componentone.com).  The MS Flexgrid is a lite version of the VS Flexgrid Pro v7.0.  The Pro version has the capability of editing directly in the grid.  It's a really great grid, so, I'd highly recommend it if you are going to be developing applications that use grids.

Now, in many cases, buying a $700 grid is not an option.  So, in that case, you might want to consider using the Excel technique, where when the user clicks on a Cell, you might highlight that cell, but then force them to enter the data in a textbox at the top of the form.  Clicking Enter or a button with a checkmark on it next to the textbox would cause the text from the textbox to be entered programmatically into the cell.

If the Cell Height and Width are large enough (I'm not sure if the MS FlexGrid supports User Resizing or not), then you could use the trick of positioning the textbox over the Cell in those cases.
0
 
LVL 4

Accepted Solution

by:
ckosloski earned 100 total points
ID: 6994930
Here is the code that I used for editing and tabing in a MSFlexGrid.

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q241355
0
 
LVL 22

Author Comment

by:rspahitz
ID: 6995015
Thanks, Joe, mdougan and ckosloski.

I addressed the scrolling issue by simply hiding the textbox when it loses focus (e.g. the user scrolls on the grid.)  And as you guessed, I'm not ready to spend $700 on a new grid control since it's only a single use on a remote form.

The MS reference was actually pretty good, and I got some good ideas from it.

I was mainly wondering if I had missed something obvious (like a property called "EnableEdit") and it seems that I didn't.

Thanks.
0
 
LVL 22

Author Comment

by:rspahitz
ID: 6995018
Oh, yeah, the reason I got the height problem was that I wanted the border on (but 3D off) so the user could more easily tell where the cursor was located.  When you do that, it goes slightly below the standard grid cell height.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now