Feature Request? Multiline issue |
Post Reply |
Author | |
sbarkeruk
Newbie Joined: 01 March 2007 Location: United Kingdom Status: Offline Points: 2 |
Post Options
Thanks(0)
Posted: 01 March 2007 at 11:06am |
I am trying to setup a multiline string property item.
I have already acheived this withthe use of the following (example) code:
wndPropertyGrid.VariableItemsHeight = True
Item.EditStyle = EditStyleMultiLine Item.MultiLinesCount = 4 However, when I edit I may want to add more than or less than the 4 lines specified here!
So is there a way of setting an 'autosize' or similar so that the height adjusts to the text size (or number of carriage returns) after the AfterEdit event?
If not then could I request this please, as it seems that a few people have been trying to do this (looking at older postings).
Simon
|
|
sbarkeruk
Newbie Joined: 01 March 2007 Location: United Kingdom Status: Offline Points: 2 |
Post Options
Thanks(0)
|
p.s. I have also read the Adding Multi-Line items tutorial, but there is still no option for autosizing. After editing to a smaller or larger text output, the row then does not look too good!
|
|
Zach
Groupie Joined: 19 July 2006 Status: Offline Points: 62 |
Post Options
Thanks(0)
|
When it gets focus... freeze the property grid... grab the current value... destroy that item.
Add back in the same place an item that is a few lines bigger than they currently have.
Use a Mono font
After its been edited run another function that you would also run if the text area's width was changed through a resize.
Get the current width of the text area.
Do the math... how many characters can fit in each line... run through the value .. you can not do simple division - you got to figure out each ... break it, then back track to the first space or other character that it would word wrap on... take the remainder... repeat until none is left.
You now know how many lines there is.... grab the value... destroy the control... add a new one in its place at the size you want.
Not as difficult as it sounds :) ... I have not done this here ... but it should work. I have on the other hand done it with a textbox in html to make an html textbox with line numbering that handled wordwrap without a problem.
(Honestly takes less than 10 lines of code.. probably more like 5)
When all done... unfreeze the propertygrid... the end user will notice nothing other than the textarea is the size of their text.
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |