|
Write your own class derived from the textbox. When the user hits enter, measure the string, if it doesn't fit, make the textbox get bigger.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi Christian
Thanks for replying.
In designer view, My textbox just fits in one line of string.
At runtime it could get a very long string.
Thus as Multiline is true the rest of the text comes in the next line and so on.
But unfortunetely my textbox size remains the same.
I need it to grow(vertically) with the numbers of line at runtime.
I dont want to use scroll bars.
could u please suggest how to go about this.
Thanks alot. really appreciate your help.
Karan
|
|
|
|
|
If you're not hitting enter to go to the next line, then you need on each keypress to use the measurestring method of hte graphics class to work out if the text is too big for the control, and if so, change it's size
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi Christian
Thanks for the reply.
Will try this.
|
|
|
|
|
Hi all
at run time i add controls to form. i set controls contextmenu property to contextmenustrip1 whish has 3 sub menus. i wanna make something to control (like changing backcolor) when user click Menu1ToolStripMenuItem.
i need like at below
Private Sub Menu1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Menu1ToolStripMenuItem.Click<br />
sender)<br />
<br />
Menu1ToolStripMenuItem.Owner .ContextMenu .attainedControl.BackColor=red<br />
<br />
End Sub
How could i find "Attained Control"
|
|
|
|
|
Hi,
the sender parameter contains the sending object, you should cast it to what you expect,
here a menu item.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
i think u got me wrong.
i wanna catch which control has that context menu which button clicked.
|
|
|
|
|
|
|
Glad to help you
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
hy everyone!
i realized a console appliction which works perfect. but i was wondering what i will have to do to change it into a service dll?
i know the easiest way is to do it as a dll from the beginning. you are able to switch to dll instead of executable in the settings but this won't create a service dll which i am able to install.
does anyone of you have something like a "cookbook" of how to change a console appliction into a service dll? because this would help me a lot and it would avoid me having to start with my program once again.
thanks.
stephan.
|
|
|
|
|
|
yes, something like that.
but it only describes a service which does a console application. but my problem is: what do i have to do to add it to the list of services? isn't there a function like "onstart", "onstop" or "onrestart" (for all the actions which could be done in the services area"?
because the article describes a console application as a service. but you do have to get it into the services first and that's my question:
what do i have to add to my application to let it be started as a service like the one in the article above?!
|
|
|
|
|
I am looking for a suggestion, or an example, on how to sync the text in a TreeView to text in a RichTextBox. My treeview is an outline of sorts and I want to allow the user to click a node and then hightlight all occurrences of the text in a RichTexBox.
I thought of using a Hashtable or Dictionary to index the outline, however, there are occasions when there are multiple keys with throws an exception.
I guess the best example is the help documentation in the Visual Studio .NET.
Thanks,
Mark
modified on Sunday, April 6, 2008 3:19 PM
|
|
|
|
|
Hi,
FYI: a TreeNode has a Tag property where you can store something, say a List of things
you want to be able to refer to later on.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hello!
Maybe anyone knows if it is possible to get in C# the SID of the user created a file or folder?
(Maybe CreatorOwner)
Thanks in advance!
Have a nice day!
|
|
|
|
|
|
Hi,
I have followed the article Asynchronous Socket Programming in C#: Part II
(link: http://www.codeguru.com/csharp/csharp/cs_network/sockets/article.php/c8781/)
I need to place the SocketServer application in a PC startup menu. So that once the SocketServer application is started after restarting the PC, the client machine can connect to server and communicate.
But I have a Client connection problem when SocketServer application luanches immediately after restarting the SocketServer application PC.
I mean when I press "Connect to Server" Button from the Client application Immediately after the SocketServer application launches after restarting that PC, The client is not connecting to server application immediately.
I need to wait at least 15 to 20 second to get the connection from Client PC to Server. But after that it works fine.
Only I face delay first time if I am trying to connect from client machine to server, When Server machine restarting.
How can I avoid this delay please help on this.
|
|
|
|
|
Came across the following code here in response to another question.
The idea was to spell check some text. I want to do the same thing, but with only instantiating the objects once. The reason for this is I'm going to be checking a ton of strings one at a time, and don't want to keep creating new objects. (good reasons for doing so, but probably not relevant)
The main question is how do I ensure only the current string is being checked? The .dll was not document friendly.
doc.Words.First.InsertBefore(tBox.Text);
Thanks to anyone who takes the time to answer this,
<br />
<br />
public void fSpellCheck(TextBox tBox, Label lLbl) <br />
<br />
Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();<br />
<br />
<br />
object template = Missing.Value;<br />
object newTemplate = Missing.Value;<br />
object documentType = Missing.Value;<br />
object visible = true;<br />
object optional = Missing.Value;<br />
<br />
_Document doc = app.Documents.Add<br />
(ref template,<br />
ref newTemplate,<br />
ref documentType,<br />
ref visible);<br />
<br />
doc.Words.First.InsertBefore(tBox.Text);<br />
Microsoft.Office.Interop.Word.ProofreadingErrors we = doc.SpellingErrors;<br />
iErrorCount = we.Count;<br />
doc.CheckSpelling(ref optional, ref optional, ref optional,<br />
ref optional, ref optional, ref optional, ref optional,<br />
ref optional, ref optional, ref optional,<br />
ref optional, ref optional);<br />
if (iErrorCount == 0)<br />
lLbl.Text = "Spelling OK. No errors corrected ";<br />
else if (iErrorCount == 1)<br />
lLbl.Text = "Spelling OK. 1 error corrected ";<br />
else<br />
lLbl.Text = "Spelling OK. " + iErrorCount +<br />
" errors corrected ";<br />
object first = 0;<br />
object last = doc.Characters.Count - 1;<br />
<br />
|
|
|
|
|
For no reason whatsoever I made a Console project with the following code:
<br />
namespace ConsoleApplication1<br />
{<br />
class Program<br />
{<br />
static void Main(string[] args)<br />
{<br />
try<br />
{<br />
<br />
bool[] damn_big_array = new bool[2147483647];<br />
}<br />
catch (OutOfMemoryException oome)<br />
{<br />
Console.WriteLine(oome.Message);<br />
}<br />
Console.Read();<br />
}<br />
}<br />
}<br />
Now 2147483647 is the max value that can be held in 31 bits(Int32 or int). I run this with TaskManager open. Despite having over 600 MB of RAM free (I have a total of 1.25 GB) I get the OutOfMemoryException. Is there some limit it how much space .Net programs can use?
|
|
|
|
|
Are you kidding?
See here [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
What are you getting at? I know int and Int32 uses 4 bytes: 1 Bit for sign and 31 for the number. So:
2^31 - 1 = 2147483647 = 01111111111111111111111111111111
Whereas uint:
2^32 - 1 = 4294967295 = 11111111111111111111111111111111
|
|
|
|
|
sizeof bool is 1 byte , hence you're asking for 2 Gb of memory.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Oh whoops my bad. lol
Thanks.
|
|
|
|
|
On a 32 bit system, each application can only address 2 GB of memory.
You are trying to allocate a 2 GB array, which is more than your computer has. Also, as the application already uses some memory (stack, heap, code) there isn't 2 GB left in the virtual address space for the application.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|