Solved

Grid text entry

Posted on 2002-05-07
5
323 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

831 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