Solved

locked cells,  need to view all contents

Posted on 2014-09-18
6
78 Views
Last Modified: 2014-09-18
I have a MSflexgrid in vb6 and have all cells locked except one using the following code:

Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)

Dim sTemp As String

With MSFlexGrid1

sTemp = .TextMatrix(.Row, .Col)

If .Col <> 10 Then Exit Sub ' This might need to be 7
Select Case KeyAscii
Case 8 ' backspace
If Len(sTemp) > 0 Then
sTemp = Left$(sTemp, Len(sTemp) - 1)
End If
Case 27 ' escape
sTemp = ""
Case 0 To 31
KeyAscii = 0
Case Else
sTemp = sTemp & Chr$(KeyAscii)
End Select
.TextMatrix(.Row, .Col) = sTemp
End With

MSFlexGridEdit MSFlexGrid1, txtEdit, KeyAscii

End Sub

Open in new window


My question is it possible to view all the contents of a cell since some cells contain large paragraphs.  Is there a way to scroll in a cell?
0
Comment
Question by:al4629740
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 47

Expert Comment

by:Martin Liss
ID: 40331047
Here is a project that is based on the floating textbox that I posted in your other thread. The changes from that demo are all marked with 'new

I placed some long text in the first two rows in column 2.
Scroll-in-cell.zip
0
 
LVL 47

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40331076
I forgot that I also changed txtEdit to MultiLine = True and Scrollbars = Vertical in its properties.
0
 

Author Comment

by:al4629740
ID: 40331448
Also I needed to make this adjustment in the code



Sub MSFlexGridEdit(MSFlexGrid As Control, Edt As Control, KeyAscii As Integer)

    ' This only happens for the 1st character entered.
    ' The other characters are typed into txtEdit.
    
     ' Changed here
    If MSFlexGrid.Col = 10 Then
        txtEdit.Locked = False
        Else
        txtEdit.Locked = True
    End If
    
    ' Use the character that was typed.
    Select Case KeyAscii

    ' A space means edit the current text.
    Case 0 To 32
        Edt = MSFlexGrid
        Edt.SelStart = 1000

    ' Anything else means replace the current text.
    Case Else
        Edt = Chr(KeyAscii)
        Edt.SelStart = 1
    End Select

    ' Show Edt at the right place.
    Edt.Move MSFlexGrid1.Left + MSFlexGrid.CellLeft, MSFlexGrid.CellTop + MSFlexGrid.Top, _
        MSFlexGrid.CellWidth, MSFlexGrid.CellHeight
     
    Edt.Visible = True

    ' Initially set the text value to whatever is in the cell
    If Edt.Text = "" Then
        Edt.Text = MSFlexGrid.Text
    End If

    ' And let it work.
    Edt.SetFocus
End Sub

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:al4629740
ID: 40331485
I have a column that is blue in column 10.  

When I make an edit in my colored column, it reverts back to white.  How can I keep the color blue?
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 40331572
Add the top of your form add this.

Option Explicit
Private mlngBackColor As Long

Open in new window

Then in the EnterCell event for you grid put
mlngBackColor = TheNameOfYourGrid.CellBackColor

Open in new window

And finally in the LeaveCell code add this line just before the txtEdit.Visible = False line.
TheNameOfYourGrid.CellBackColor = mlngBackColor

Open in new window

0
 

Author Comment

by:al4629740
ID: 40331928
This is what worked

Private Sub MSFlexGrid1_LeaveCell()

    'I removed this line below because the whole grid would remain white
    'MSFlexGrid1.CellBackColor = vbWhite
    
    If txtEdit.Visible = False Then Exit Sub

    
    MSFlexGrid1 = txtEdit
    MSFlexGrid1.CellBackColor = mlngBackColor
    txtEdit.Visible = False
    
    

End Sub

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
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…

726 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