|
Well... It's very strange, but if I use a GraphicsPath object instead of a Region object as the "trans" variable, it works!
|
|
|
|
|
Hi.
I am doing notepad.
I have some problems and I need your help of the following:
1. I want know exactly whether an Event occurs or not?
For example: if we have a texbox, how can we know there is achange [Even occurs] on the texbox for our creating a proper control flow.
2. During the finding progress by using Find order, how can we define the position of the cussor at the points of finding and how can we select the match string/characters.
I would thank you in advance for your helpful assistances and look forward to hearing from you soon.
|
|
|
|
|
nguyenquang0284 wrote: For example: if we have a texbox, how can we know there is achange [Even occurs] on the texbox for our creating a proper control flow.
By catching the keypress event, or the text changed event.
nguyenquang0284 wrote: During the finding progress by using Find order, how can we define the position of the cussor at the points of finding and how can we select the match string/characters.
There are selectionstart and selectionlength properties on a text box, from memory
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Shy Christian Graus,
Thank you very much your prompt and useful response.
For my first question, I would like to further clarify as follow cause there may be some unclear
Actually, I wish to control Even TextChange that occurs in textbox when I change text in richtextbox.
For example, when using "Open" commence of Notepad, if there is a change on the content of richtextbox, a message informing that "Do you want to save the change?". In case the button "Yes/No" is pressed, an openfile dialog is presented for our choosing any file we wish. Otherwise (there is no change on the content of richtextbox), an openfile dialog will appear for our choosing.
I am therefore highly expected that you would advice me how to handle/proceed/control EvenChange like the referred.
Secondly, I want build a function "Goto Line" in Notepad.
My function Goto Line includes:
- A Form named frmGoto
- The function can receive possitive number:
- If you put the possitive number in textbox of Form:
[Number 2,i.e]
The cursor then will move to Line 2. of Notepad.
Therefore, could you please help me to build such Function.
Thank you very much for your kind assistance and look forward to hearing from you at your most conveniance.
Best regards,
Quang
|
|
|
|
|
1 - you need a boolean flag that you set to true the first time someone types something. Or you need to store the text and compare it with the text in the textbox at the point that you want to know if the text has changed
2 - I believe the only way to work out line numbers is to count the number of times there are carriage returns in the text. They are actually two characters, Environment.NewLine is the way to create them.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
nguyenquang0284 wrote: how can we know there is achange
Subscribe to the TextChanged event on the TextBox. I think this is the default event, so double clicking the text box in the design window should wire up the event for you.
nguyenquang0284 wrote: how can we define the position of the cussor
I think the position of the "cussor" is generally someone who is angry about something. But I guess you really meant "cursor".
nguyenquang0284 wrote: how can we select the match string/characters
Use SelectionStart[^] and SelectionLength[^]
|
|
|
|
|
Shy Colin Angus Mackay,
Thank you very much your prompt and useful response.
For my first question, I would like to further clarify as follow cause there may be some unclear
Actually, I wish to control Even TextChange that occurs in textbox when I change text in richtextbox.
For example, when using "Open" commence of Notepad, if there is a change on the content of richtextbox, a message informing that "Do you want to save the change?". In case the button "Yes/No" is pressed, an openfile dialog is presented for our choosing any file we wish. Otherwise (there is no change on the content of richtextbox), an openfile dialog will appear for our choosing.
I am therefore highly expected that you would advice me how to handle/proceed/control EvenChange like the referred.
Secondly, I want build a function "Goto Line" in Notepad.
My function Goto Line includes:
- A Form named frmGoto
- The function can receive possitive number:
- If you put the possitive number in textbox of Form:
[Number 2,i.e]
The cursor then will move to Line 2. of Notepad.
Therefore, could you please help me to build such Function.
Thank you very much for your kind assistance and look forward to hearing from you at your most conveniance.
Best regards,
Quang
|
|
|
|
|
You didn't have to repeat your question 4 times.
|
|
|
|
|
Hi,
For you first question, you have to register for the TextChanged event.
If you're new to this, I suggest you read some articles about events and delegates[^], as this is not the place to teach you that, I believe...
As for selecting text in a TextBox, you can use the Select() function of TextBox, or
use the SelectionStart and SelectionLength properties to do that.
Best Regards,
Shy.
|
|
|
|
|
Shy dear,
Thank you very much your prompt and useful response.
For my first question, I would like to further clarify as follow cause there may be some unclear
Actually, I wish to control Even TextChange that occurs in textbox when I change text in richtextbox.
For example, when using "Open" commence of Notepad, if there is a change on the content of richtextbox, a message informing that "Do you want to save the change?". In case the button "Yes/No" is pressed, an openfile dialog is presented for our choosing any file we wish. Otherwise (there is no change on the content of richtextbox), an openfile dialog will appear for our choosing.
I am therefore highly expected that you would advice me how to handle/proceed/control EvenChange like the referred.
Secondly, I want build a function "Goto Line" in Notepad.
My function Goto Line includes:
- A Form named frmGoto
- The function can receive possitive number:
- If you put the possitive number in textbox of Form:
[Number 2,i.e]
The cursor then will move to Line 2. of Notepad.
Therefore, could you please help me to build such Function.
Thank you very much for your kind assistance and look forward to hearing from you at your most conveniance.
Best regards,
Quang
|
|
|
|
|
Shy dear,
Thank you very much your prompt and useful response.
For my first question, I would like to further clarify as follow cause there may be some unclear
Actually, I wish to control Even TextChange that occurs in textbox when I change text in richtextbox.
For example, when using "Open" commence of Notepad, if there is a change on the content of richtextbox, a message informing that "Do you want to save the change?". In case the button "Yes/No" is pressed, an openfile dialog is presented for our choosing any file we wish. Otherwise (there is no change on the content of richtextbox), an openfile dialog will appear for our choosing.
I am therefore highly expected that you would advice me how to handle/proceed/control EvenChange like the referred.
Secondly, I want build a function "Goto Line" in Notepad.
My function Goto Line includes:
- A Form named frmGoto
- The function can receive possitive number:
- If you put the possitive number in textbox of Form:
[Number 2,i.e]
The cursor then will move to Line 2. of Notepad.
Therefore, could you please help me to build such Function.
Thank you very much for your kind assistance and look forward to hearing from you at your most conveniance.
Best regards,
Quang
|
|
|
|
|
If you want to display a dialog box upon an "Open" menu item, you don't need to catch the TextChange event of the textbox...
What you want to do is catch the Click event of the menu item, and display the dialog through there.
And just a little tip... Applications with an "Open" buttons, usually show the dialog prior to asking whether changes should be saved.
If the user selects a file, and presses the "OK" button or "Open" or whatever, then you display a messagebox prompting for saving changes.
If the user presses the cancel button in the "Open" dialog, you just do nothing.
As for your function...
There's no built in function in a textbox that gives you the ability to jump to a specified line.
Therefore, try using the following:
private void JumpToLine(int line)
{
int position = -1;
int currLine = 0;
while ((position = textBox1.Text.IndexOf('\n', position + 1)) > 0 && currLine++ < line) ;
if (position == -1) return;
textBox1.SelectionStart = position;
textBox1.Focus();
} Notice the semicolon (";") after the "while" statement.
|
|
|
|
|
Dear Shyagam!
Thank you so much for your instructions. They are very useful for me and help me to solve my problems. I hope that I will continue to be received your help in the coming time. I'm also ready to help you if I can.
Your sincerely
Quang
|
|
|
|
|
Hi there
I've been a heavy user of the 'Exceptions' window in the IDE for a long time now. Its never really crossed my mind until now.... But aren't 'Thrown' and 'User-unhandled' mutually exclusive. As in if you have Thrown checked then 'User-unhandled' might as well not be checked?
Thanks
Rich
|
|
|
|
|
Hi
in a video conferencing application i want to add logo in byte data of captured image from web cam before sending this image to clients. can anyone tell me how should i do this.
thanks
|
|
|
|
|
I'm totally new to C# and needs this question answered.
I call Form2 from From1, so I have two windows not. If I move my mouse over and click on Form1, it comes to the foreground; but I don't want this. I want to require myself to close Form2 and have it return me to Form1. Examples of code for this would be greatly appreciated.
|
|
|
|
|
Use form2.ShowDialog() instead of form2.Show();
|
|
|
|
|
Hi,
How can I get a deep copy of an array of classes? The class implements ICloneable, and when I try to get a deep copy of it when it's not in an array it works fine:
class A : ICloneable
{..........}
A aa=new A();
A bb=(A) aa.Clone();
but if I have an array of classes it doesn't:
A[] arrA=new A[3];
//init the array here
A[] arrB=(A[]) arrA.Clone(); //this gives me a shallow copy
One way to do it is to explicitelly clone each element:
A[] arrB=new A[3];
for (int i=0;i<3;i++)
arrB[i]=(A) arrA[i].Clone();
Is this the best way to do this? Thanx!
|
|
|
|
|
The Clone method always creates a shallow copy. If you want a deep copy you have to clone each object.
---
b { font-weight: normal; }
|
|
|
|
|
What is the best solution for displaying on a web page page a
collection of records where each record is to be conditionally
tested and then displayed with formatting based on the conditions within each record.
Example: A series of 50 records is retrieved from database consisting
of a company name, company phone number and state. Also included in
each record is a season code. Task is to display the company name,
state and conditionally display the phone number.
In cases where the records season code matches a predefined value the company name will appear in bold type and the phone number will display.
Do any of the .net 2.0 data controls allow you to conditionally format
the appearance of record components as they are written to the
webpage?
Thank you,
antar007
|
|
|
|
|
I have a question that I hope somebody has figured out. Visual Studio 2005 is definately a productive environment, that goes without saying, but there are a occasionally annoyances that you wonder what they were thinking.
My annoyance question is how do you cause double-click to "View Code" in solution explorer rather than "View Designer". I have been using the environment for about three years now and I can't and I still can't get used to this being the default option.
Its not that it is such a big deal in and of itself but I am forever double-clicking to edit the code and then I get the designer that I didn't want, which I have to close and then reopen the same node with "View Code".
Double click is instinctive for open so I don't use the buttons.
Is there a way to change the option to open in "View Code" when double clicking? I (like most probably) have a 10:1 ratio of editing code versus UI. There are times you want to edit the forms/controls, of course, but, that is the exception.
Anyone know a way to change this? Is it possible?
Thanks,
Jim
|
|
|
|
|
It's possible to set up the preferences to view code and not designer for web pages, perhaps that option is in there as well. I am quite used to right clicking and hitting 'view code', tho. You can also set the solution explorer to show the .cs file under the designer file like a tree view, then you can select the file you want and double click on it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi Christian,
I don't see a place to do that with the C# editor. So its obvious that Microsoft realizes there a is a preference between the code/design views. Double clicking has always opened CPP files, including dialog and control files in the old VS's. Of course they were separated in those days. It was a good idea to integrate them into Solution Explorer. I am hoping there is a registry settings or something if not comprehended in the Options. I figure it was an oversight.
Of course this is not "earth-shattering", I mean all you have to do is right click and navigate down the menu, its just an annoyance when you are deep in concentration.
Jim
|
|
|
|
|
Show all files is in the solution explorer, but while that helps for ASP.NET, it doesn't seem to help for winforms. Perhaps there isn't a way ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
You just may be right. Bummer...
|
|
|
|