Solved

Setting a column header italic in MSFlexGrid

Posted on 2000-02-16
8
925 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
[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
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses
Course of the Month10 days, 3 hours left to enroll

624 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