|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (7 bit)
|
Visual Basic - Adjusting grid columns width
HI,
Grid column width is measured by pixels by default. I want to set it by characters (after counting for each column the maximal length word that it would present) But trying to use Me.ScaleMode = 4 (which supposed to be Characters mode) not works for me. |
|
|
|
|
|
#2 |
|
Member (7 bit)
|
Anyone can help me with this one please ???
I just want to show some table in gird. But dont want to make column width constant predefined, but instead set in runtime. Thus i count the words length, but how then i set the column with of the grid.... |
|
|
|
|
|
#3 |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
An easy way to do this is assume each letter is X pixels long (I will use 10 for this example). After you have put the text in the box, simply readjust the size.
Psuedocode: Code:
Const CHARPIXEL = 10 strData = "this is a test" GridCell.Text = strData GridCell.Width = Len(strData) * CHARPIXEL Not the most elegant, but it gets the job done. |
|
|
|
|
|
#4 |
|
Member (7 bit)
|
ye i search the maximal width.
and i even have function giving me exactly the values of the character pixels (height and width). problem is it not works good enough on different sizes of words. i tried. in some point (large once) it swallows last letter and on small values it have more free space. i mean there is probably different character sizes (depends by the letter) or it has spaces between them. i dont know. it is possible to change scalmode, for example to characters but it not works either. or i just do something wrong... try for 3 different words: kkk, kkkkkkk, kkkkkkkkkkk and see the differences... its not so good way. but tnx anyway
|
|
|
|
|
|
#5 |
|
Member (7 bit)
|
ScaleX(1, 4, 1) * len(gridcell.text) or Scale(len(gridcell.text), 4, 1)
scale will convert from chars to the form measurements. |
|
|
|
|
|
#6 |
|
Professional gadfly
|
Is the problem the fact that you are not using a fixed-width font? That would probably screw up simple character-to-pixel computations.
|
|
|
|
|
|
#7 |
|
Member (7 bit)
|
maybe maybe.
i use the default font which is: MS Sans Serif does this font is not fixed-width? (i guess not) then what shall i use... and i checked now when i use letters like 'q' or 'w' is screws it all cuz they are the longest. |
|
|
|
|
|
#8 |
|
Professional gadfly
|
Nope, that's not fixed width. Courier is, though.
|
|
|
|
|
|
#9 |
|
Member (7 bit)
|
There is Courier and Courier new.
Courier all font sizes are big - starts with 10. and when i use it all go above the calced text box size. When i use font size 8 with Courier New, it still not improvement. I think it has some deal with font size too..... ScaleX( Len(text), 4, 1) prolly designed for specific font size |
|
|
|
|
|
#10 |
|
Member (7 bit)
|
HELP ME plz.
Courier is not fixed size, because when i use it, i still have too much space left afterwards.. And what about the font size..? |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|