|
Well, you can always catch the exception in Parse
Also, Parse is .NET 1.1, while TryParse is only .NET 2.0
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Every thing will come to you if you have faith.
|
|
|
|
|
hi every one
I just wanted to know how can we make a combo box in a datagrid. I'm working in Windows Forms and in .net 1.1.
iknow its easy to do in .net 2.0 but I'm not working in it!!
thanks in advance!
Rocky
|
|
|
|
|
im getting crazy here
i have a c# application in which i have client and server.
there is no continuing connection between them
every time the client want something , he open the connection and query...
i also have a function which called : run_sql_select_command
in it , i have try and catch if there is no database ( or other problem).
the problem is that i want , IF ERROR , IN THE CATCH , goto the login screen.
i have just 1 form.
the program going to the login and then COMEBACK to the function !!!!!!! ( i dont want it - i want it to stay at the login section)
i tried goto , but it is not in the scope,
what can i do ??
please,.
|
|
|
|
|
while(true)
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Your design is flawed, and shows a poor grasp of how .Net works works.
|
|
|
|
|
Hey all,
I'm writing a class named ShapedForm.
It inherits from System.Windows.Forms.Form.
What I'm trying to accomplish is a built in functionality to make a non-rectangular form (i.e. a shaped form), and other functionalities such as form dragging with no title-bar.
I wrote this function:
public void ShapeTheForm(Bitmap ShapeImage, Color Key)
{
if (busy) return;
busy = true;
Region trans = new Region();
trans.MakeEmpty();
int width = ShapeImage.Width;
int height = ShapeImage.Height;
for (int y = 0; y < height; ++y)
for (int x = 0; x < width; ++x)
{
Color pixel = ShapeImage.GetPixel(x, y);
if (pixel.R == Key.R && pixel.G == Key.G && pixel.B == Key.B)
trans.Union(new Rectangle(x, y, 1, 1));
}
Region tempRegion = new Region(new Rectangle(0, 0, ShapeImage.Width, ShapeImage.Height));
tempRegion.Exclude(trans);
lastStyle = FormBorderStyle;
if (InvokeRequired)
Invoke(new LayoutSetDelegate(SetShapedLayout), ShapeImage, tempRegion);
else
{
FormBorderStyle = FormBorderStyle.None;
Size = new Size(ShapeImage.Width, ShapeImage.Height);
Region = tempRegion;
BackgroundImage = ShapeImage;
}
trans.Dispose();
trans = null;
busy = false;
} It worked earlier, and I can't see the problem now.
When I call the function, the debugger lands on this line:
Region = tempRegion;
I get a StackOverflowException in System.Drawing.dll...
Do you see any problem with my code?
Any ideas why assigning the region fails?
Thanks in advance,
Shy.
|
|
|
|
|
Hi!
If it worked before and now doesn't, chances are that you changed something else...
Could it be that setting the Region property of your form calls ShapeTheForm() again and your busy -Flag doesn't work?
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Hmm... I suppose the scenario you've described above is not taking place, as I did Step-By-Step debugging and when I get to this specified line an exception is thrown...
So... There's no inifinate loop/recursion happening here...
|
|
|
|
|
Did you override/'new' Region ?
|
|
|
|
|
|
I've just discovered that if I use a different color then the transparent color as the key, no exception is thrown.
The function completes successfully, and the region stays the complete region, without any transparent parts...
|
|
|
|
|
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
|
|
|
|
|