Block Selection

George7a
06-20-2006, 02:04 AM
Hi,

I want to be able to select a block and change the font of this block using VB.NET. I have asked a similar question before 1 year when I used to use VB6 but now I am working with VB.NET (VS 2005). So while I am searching, one of the options were to sub-class a RichTextBox and let it be possible to select a block instead of a line (see attached jpg) but I wasn't advised to do so using VB6.

Other options were:

1) Picture box (it is easy (thanks to passel) to select but hard to change the font)
2) Grid Object (didn't look nice with VB6 - Not WYSIWYG)
3) Sub-Classing a RichTextBox (is it doable?)

What do you advice me to use & why?

Thanks in advance,

- George

MikeJ
06-21-2006, 09:56 AM
Why don't you use a DataGrid? In .NET, it is a part of the Windows.Forms namespace, so it's a native control. Also, data handling in .NET is heads over heels better than VB6. Check out the DataGrid and don't bother with the rich text box.

George7a
06-22-2006, 01:31 AM
Thank you MikeJ for your reply.

I tried to use a DataGrid. The idea here will be that every letter will be in a cell. It does not look good because there will be a pixel or two between more between every letter & letter which makes the letter look a little far from each other. I tried to put GridLineStyle = NONE and the color white, but still it does not look good. Can I subclass this and make it reay NONE as for zero?

Any other ideas?

- George

George7a
06-27-2006, 05:35 AM
I have thought also of

1) sub-classing the DataGrid, hopefully to remove the gridline totally
2) sub-classing the RTB and change the way that the select works (is it doable?)
3) Trying to draw a rectangle on the RichTextBox and then to calculate which letters are inside the rectangle. But if the font wasn't fixed width?! How can I do it?

P.S. I still do not know how to draw on a RichTextBox. I think this part is doable but I don't know how nice it will look. In VB6 it didn't look good.

Please share your thoughts.

- George

MikeJ
06-27-2006, 10:01 AM
I'm telling you. Don't use the RichTextBox. Bad bad bad. ;) It's the totally wrong solution to this problem. Set the DataGrid's GridLineStyle to None.

George7a
06-28-2006, 12:05 AM
I have already siad that I have tried that! It looks bad! Check the attachment:

Even when I put the GridLine = NONE there will be still a part that none of the cells can write on. I have tried to put another font and change the cell size but still... I even made an application that can let you choose the best font & cell size but NO ONE was good enough (check the attachment). Any Idea why (same problem I had with VB6)? I must put every letter in a cell so I can change every thing.

MikeJ
06-28-2006, 12:10 AM
Have you tried CrystalReports or some other reporting tool? To get functionality like you want, you will either have to code it yourself, subclass and force it to do what you want, or go to 3rd party tools.

(Also, just wondering, why does every letter have to be in it's own cell? This is not the way most reporting tools work, so it seems like you're trying to make a square wheel! ;) :))

George7a
06-28-2006, 12:16 AM
I didn't try Crystal Reports yet. I will soon. Thanks for sharing

So you advice me to subclass the Grid (if crystal reports didn't work)? And I should forget about subclassing the RTB or drawing on it.

Than ks again for your help,

- George

MikeJ
06-28-2006, 12:18 AM
The RichTextBox is not meant to behave in the way that you are looking. It is inadvisable to do this because you really would be making square wheels - it's meant to be used to display linear data, not tabular data. Definately scrap the RichTextBox idea, check into CrystalReports (I believe it comes with several versions of .NET) and if that doesn't work, try to subclass the grid.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum