Solved

Setting a column header italic in MSFlexGrid

Posted on 2000-02-16
8
879 Views
Last Modified: 2008-02-26
I am trying to set a column header of a MSFlexGrid italic when the form loads for the first time. The grid has only one header row and several columns. I have noticed that even if there is only one row, the value of MSFlexGrid.Row =1.However, when I do the following, I get a runtime error on the 3rd line:

1)MSFlexGrid.Row = 0
2)MSFlexGrid.CellFontItalic = True
3)MSFlexGrid.Row = 1

I would like the Row value 1 which is what it originally is but if I set it back to 1 as in line 3, I get a run time error.

Musleh

0
Comment
Question by:mfarid1
8 Comments
 
LVL 3

Expert Comment

by:MTroutwine
ID: 2527461
What do you have MSFlexGrid.FixedRows set to?
0
 

Expert Comment

by:tcornett
ID: 2527579
Musleh,

If you are getting the error #30009: Invalid Row Value, then it is most likely because your recordset is empty.  If the flex grid only contains the field names and no data (because your recordset is empty) then you cannot go to row 1 becauase it will not exist.  You may want to try putting an If..Then statement in your code to handle this.  For example:

MSFlexGrid.Row = 0
MSFlexGrid.CellFontItalic = true

if rsRecordset.RecordCount > 0 then
  MSFlexGrid.Row = 1
end if

Try this and let me know how it works.

- Tom
0
 
LVL 20

Expert Comment

by:hes
ID: 2527992
In the properties of the grid set rows to 2 and fixed rows to 1
0
 

Author Comment

by:mfarid1
ID: 2528017
To MTroutWine, MSFlexGrid.FixedRows =1

To hes, I don't want to have FixedRows and Rows different. When there is no data I don't want to show an empty row.

To tcornett, you are talking in the context of a recordset. Actually, what I want to know is, if we have a grid with just 1 row and that is a fixed row, how do we set the first column header to italic?

0
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.

 
LVL 3

Accepted Solution

by:
MTroutwine earned 50 total points
ID: 2528078
Here is what worked for me.  I created a new project in VB added the MSFlexGrid Control.  Right-click on the control and set both the Rows and FixedRows values to zero... yes you will get a message saying you cannot do that but click OK on it and then click OK on the property sheet to close it.  Next add this code to the form load event:

With MSFlexGrid
    .Rows = 2
    .FixedRows = 1
    .Rows = 1
    .Font.Italic = True
    .Col = 0
    .Text = "Test"
end with

Hope this is what you are looking for!
:>)
0
 

Expert Comment

by:tcornett
ID: 2528082
mfraid1,

If you have just one row, and that row is fixed, then that row is row number 0.  Row number 1 at this time does not exist. So if you want to set it to italic, do what you were doing above but omit the MSFlexGrid.Row = 1 for this line will give an error due to the fact that Row 1 does not exist.

If you want to leave the MSFlexGrid.Row = 1 line in the code, then you may want to try using On Error Resume Next.

Hope this helps and good luck!

- Tom
0
 
LVL 3

Expert Comment

by:MTroutwine
ID: 2528087
One quick mistake in my statement above, after you get the message about the Fixed Rows must be 1 less then the Rows count and click OK to close that messagebox.  Click on the Cancel button on the property page window not the OK button.  Sorry...
0
 
LVL 3

Expert Comment

by:MTroutwine
ID: 2528096
One more thing, to get the message box from the property page you must click the Apply button.  Sorry again.  Having one of those days!
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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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…

920 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

14 Experts available now in Live!

Get 1:1 Help Now