5 Replies - 1432 Views - Last Post: 28 December 2013 - 04:45 PM Rate Topic: -----

#1 playared  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 28-December 13

DataGrid text jump

Posted 28 December 2013 - 11:32 AM

I have a DataGrid two columns and during execution when I click on the first cell to select it the text jumps to the left showing only part of the text in cell. This does not happen if I click the arrow on the left of the row.

How can I stop the text jump?

Thanks,
playared
Is This A Good Question/Topic? 0
  • +

Replies To: DataGrid text jump

#2 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3721
  • View blog
  • Posts: 12,953
  • Joined: 12-December 12

Re: DataGrid text jump

Posted 28 December 2013 - 11:54 AM

If it jumps to the end of the text doesn't this mean that the amount of text is wider than the column? Can you not just increase the width of the column? (Note, I don't have VB6 to play with.)

What behaviour would you want instead? (Personally, I would just accept the default behaviour.)
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3721
  • View blog
  • Posts: 12,953
  • Joined: 12-December 12

Re: DataGrid text jump

Posted 28 December 2013 - 12:01 PM

Anyway, a quick look around suggests that you could do something on this event:

Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)

End Sub

http://msdn.microsof...3(v=vs.60).aspx

I don't know if VB6 has sufficient granularity to allow you to modify the selection (in the cell), otherwise you may have to use SendKeys to get the behaviour you want.

This post has been edited by andrewsw: 28 December 2013 - 12:03 PM

Was This Post Helpful? 0
  • +
  • -

#4 playared  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 28-December 13

Re: DataGrid text jump

Posted 28 December 2013 - 03:31 PM

Thanks!

More investigation shows the text reduces from 30 char to 6 char. The width holds the 30 char and is the same with on the DataGrid after shorting to 6 char.

The change occurs at End Sub following code.

Private Sub dgLaminate_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
    'this gets the Identification and Laminate ID when the col/row is clicked or selected

On Error GoTo SubError
    If dgLaminate.Columns(0).Text = "" Then
        glngLaminateID = 0
    Else
        glngLaminateID = dgLaminate.Columns(0).Text
    End If
    If gstrWhichForm = "frmOptionselectionMenu" Then
        gstrIdentification = dgLaminate.Columns(1).Text
    End If
    cmdPrint.Enabled = True
    cmdPrint.SetFocus
    Exit Sub
    
SubError:
        'call AppError - for information on AppError see basUtility
    Call AppError(mstrFrmName, mstrErrorMsg, "dglaminate_RowColChange")
    Exit Sub
End Sub


This post has been edited by andrewsw: 28 December 2013 - 03:37 PM
Reason for edit:: Fixed code tags

Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3721
  • View blog
  • Posts: 12,953
  • Joined: 12-December 12

Re: DataGrid text jump

Posted 28 December 2013 - 04:04 PM

I'm not sure if you are still asking a question?

You seem to have tracked down the issue, although your description doesn't fit the code that you've posted, so presumably you've located the code that is causing your problem.
Was This Post Helpful? 0
  • +
  • -

#6 playared  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 28-December 13

Re: DataGrid text jump

Posted 28 December 2013 - 04:45 PM

andrewsw,

When I open the window the DataGrid shows one row and one cell with the cell showing "13 Ply Test Laminate - 145 AFW Material".

When I click the cell to select it, the above code runs and at End Sub the cell shows "13 Ply Test" in blue.

After clicking the cell the user can show or print a report by clicking a commandbutton on the same form.

If I click the arrow on the left of the row to select it same code runs in "
Private Sub dgLaminate_Click()" and the "13 Ply Test Laminate - 145 AFW Material" remains all in black.

Why the change when the cell is clicked?

thanks,
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1