Solved

msflexgrid

Posted on 2000-02-18
10
267 Views
Last Modified: 2008-03-06
how do you make a particular cell black? and how can you set the column width so that they are exactly the width of the column header caption?

sorry about the 8 points...thats all I've got
0
Comment
Question by:rukiman
10 Comments
 
LVL 6

Expert Comment

by:Marine
ID: 2537521
Ok you can make the width of a column by using FlexGrid.ColWidth property set it to the number so it be a good size. Then taking about the background color is not as easy. THe problem as follows. Background is set not for one cell but for all. It can be done i would think for a range of rows. YOu can however set the forecolor of the cell very easily . flexgrid.cellforecolor = vbRed.
0
 
LVL 1

Accepted Solution

by:
tirupur_selva earned 10 total points
ID: 2537524
To change  any cell color, first you have to set the row and column.

Flexgrid1.Row = 1
Flexgrid1.col = 1
Flexgrid1.CellBackColor = &H00000000&
Flexgrid1.CellForeColor = ....

This will set the 1st row 1st column to black. Likewise you can change the fore color, you can make the cell font bold etc.

I dont think there is anything specific to set the same width as the column header caption. You have set the width during design time by trial & error method only.

Regs
Selva
0
 
LVL 2

Expert Comment

by:adityau
ID: 2537529
You use the formatstring property. It will automatically set the width of the column as same as the width of the text.
0
 

Author Comment

by:rukiman
ID: 2537943
kudos to selva for the backcolor problem.

I can't use the .formatstring method because I'm getting the information from a database.

The MSHflexgrid has a .colwidth method that sets the column width.

I can make use of  .colheadercaption to get the string in the column header, however how do I find out the number of twips the string takes, so that I can make use of .colwidth method.
0
 
LVL 6

Expert Comment

by:Marine
ID: 2538062
Ruki you ignored by answer ? you didnt' read it ?
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.

 

Author Comment

by:rukiman
ID: 2539561
sorry marine!
Yes I did read it. But I was hoping I could set it at runtime coz when I'm reading from a database, I can't make any assumptions of the width of the cols.

Gee, the response was great, quite a few people have helped me out,  I don't quite know how to split the few points I have.
0
 

Author Comment

by:rukiman
ID: 2539564
Adjusted points to 18
0
 

Author Comment

by:rukiman
ID: 2539566
Btw, I still wondering about the col width problem :)
0
 
LVL 6

Expert Comment

by:Marine
ID: 2539679
colwidth gives  a width for a column here is the example
for i = 0 to msFlex.cols-1
    msFlex.colwidth(i) = 1200
next
this code will set each column in a grid to 1200 in width
to do only one column or other columns alone you have to do this
msFlex.colwidth(1) = 100
or
msFlex.colwidth(5) = 700
this will set column 1 and 5 only to specified width.
0
 

Author Comment

by:rukiman
ID: 2541444
Thanks Selva for your help on the background color
and thanks to Marine for the help on colwidth and everyone else who replied!
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

Suggested Solutions

Title # Comments Views Activity
how to open Waze.com/livemap from address saved in DB? 26 178
Access 2016 VB code 9 103
Excel - Save a copy of work book 13 83
Macro Excel - Multiple If conditions 2 65
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

862 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

24 Experts available now in Live!

Get 1:1 Help Now