Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Setting a column header italic in MSFlexGrid

Posted on 2000-02-16
8
Medium Priority
?
938 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
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!

 

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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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

715 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