Solved

Grid text entry

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Controlling which port to download from 4 71
VBA: Add rows to listbox based on criteria 7 73
vb6 connector to SQL Server 2 34
Macro Excel - Multiple If conditions 2 63
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

911 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

22 Experts available now in Live!

Get 1:1 Help Now