Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 23rd, 2005, 05:56 AM
Authorized User
 
Join Date: Feb 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default MSHFlexgrid

Hi

I have now tried to accomplish the following task for some time,

What I want to do is the following.
When I click on a cell I want to change the color properties of that cell.
Works nicely.
    MSHFlexGrid1.CellBackColor = &H0
    MSHFlexGrid1.CellForeColor = &H80000005
When I then click another cell, I want the already chosen one to
be set back to the previous state, which actually just is the
reverse.
Any ideas

Thanks in advance
Karsten




 
Old February 23rd, 2005, 02:00 PM
Authorized User
 
Join Date: Feb 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Again

I solved the problem, it not looking nice, but it works.

Public Chosen, NowChosen as Long

Private Sub MSHFlexGrid1_Click()
    Chosen = MSHFlexGrid1.RowSel
    MSHFlexGrid1.CellBackColor = &H0
    MSHFlexGrid1.CellForeColor = &H80000005
    If NowChosen <> 0 Then
        With MSHFlexGrid1
            .Row = NowChosen
            .CellBackColor = &H80000005
            .CellForeColor = &H0
        End With
        MSHFlexGrid1.RowSel = Chosen
    End If
    NowChosen = MSHFlexGrid1.RowSel
    MSHFlexGrid1.Row = Chosen
    MSHFlexGrid1.SetFocus
End Sub

Cheers
Karsten


 
Old February 23rd, 2005, 04:09 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Careful with the statement:

Public Chosen, NowChosen as Long

In VB, Chosen will be a Variant. If you want a Long, like in this case, you have to declare it:

Public Chosen as long, NowChosen as Long

Even if it doesn't look nice, your solution is the way to go
Marco
 
Old February 25th, 2005, 02:49 AM
Authorized User
 
Join Date: Feb 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Marco
Not because I want to argue, but when i looked in MSDN, it said.

From MSDN.

Col, Row Properties (MSHFlexGrid)

Returns or sets the coordinates of the active cell in an MSHFlexGrid. These properties are not available at design time.

Syntax

object.Col [=number]
object.Row [=number]

Syntax for the Col and Row properties has these parts:

Part Description
object Anobject expression that evaluates to an object in the Applies To list.
Number A Long value that specifies the position of the active cell.

Cheers
Karsten



 
Old February 25th, 2005, 04:07 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

well, that is exact what I meant: both Chosen and NewChosen must be Long. In your declaration, Chosen was a Variant
Marco





Similar Threads
Thread Thread Starter Forum Replies Last Post
MSHFlexGrid Headings Awesomo Beginning VB 6 1 August 6th, 2006 05:21 AM
mshflexgrid kolani VB Databases Basics 0 September 28th, 2005 05:54 PM
mshflexgrid kolani Beginning VB 6 0 September 28th, 2005 05:09 PM
mshflexgrid jothi Pro VB 6 1 August 12th, 2004 03:40 AM
MSHFlexGrid Sample hello2lu Access VBA 0 July 10th, 2004 11:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.