|
The simplest way to check if a text is a number or not is to convert it :
try {
Convert.ToInt32(myTextBox.Text);
}
catch
{
MessageBox.Show("Invalid Entry", "Error!");
}
I hope you understand...because is a rough world out there...
|
|
|
|
|
I have a RichTextBox control with a vertical scroll; however, the vertical scroll is not always active depending on the height of my control.
Is there a way to figure out when the vertical scroll becomes visible on the control?
Reason I need is to calculate the number of characters per line and to do it I use method GetCharIndexFromPosition(pointAtRightCorner) and the pointAtRightCorner variable depends on whether vertical scroll is active or not.
|
|
|
|
|
Hi guys,
Does anyone know how I can capture the event when a user clicks the Minimize button on the control box in C#?
I want to issue a warning messagebox when they click on it. And why does the message box show nothing on it, even though I have set all the parameters in the messagebox function properly? There are nothing on it except an empty button with no caption.
Please help...
|
|
|
|
|
In order to catch the minimize event of an window you moust intercet the WM_SYSCOMMAND message and check that the WParam is SC_MINIMIZE. How can you do this? Simple, override the WndProc of your form :
protected override void WndProc(ref Message m)
{
if(m.Msg == 0x112)
{
if(m.WParam.ToInt32() == 0xf020)
{
return;
}
}
base.WndProc (ref m);
}
I hope you understand...because is a rough world out there...
|
|
|
|
|
Hook the Resized event of the form and then check that the WindowState is equal to FormWindowState.Minimized. If it is, issue your messagebox and do anything else that you want to.
|
|
|
|
|
(Could anyone please help me out with their expertise in writing web custom user controls. Basically i need to add around 5 custom properties to all the existing controls.
Web Content page will have a XMLDataSource set up on the page. When other controls(like textbox, dropdown, radio, label controls etc.) should have properties like DataSource, DataMember , DataTextField and DataValueField.
DataSource property should be a dropdown with the list of available datasources on the content pages(basically xmlDataSources).
DataMember property should display all the tables present in the selected XML of xmlDataSource on the web page.
Similarly DataTextField and DataValueField should display all the members under the table(selected in DataMember).
Could you please send a sample code to do this.
Thanks in advance.
Murali
Rangam
|
|
|
|
|
thanks for the help about method i solved that one
another thing now:
console apllication
int[,] alfa={{1,2,3},{4,5,6}};
how can i implement a method that includes alfa array as an argument and show in the console all it´s elements?
P:S. i apreciate for the help, and yes guffa i am not being able to solve some exams that i have and it helps a lot +- 2000 programers help
|
|
|
|
|
A very simple solution to your answer is the following method :
static void Mehtod(int[,] alfaArgument)
{
Console.WriteLine("Argument values : " +
alfaArgument[0,0] + ", " +
alfaArgument[0,1] + ", " +
alfaArgument[0,2] + ", " +
alfaArgument[1,0] + ", " +
alfaArgument[1,1] + ", " +
alfaArgument[1,2]);
}
A more laborious method that can wrote on the screen the contents of an array with more then two dimensions is the following :
static void Mehtod(int[,] alfaArgument)
{
long[] indexes = new long[alfaArgument.Rank];
for(long i = 0 ; i < indexes.LongLength ; i++)
indexes[i] = 0;
while(true)
{
string argument = "";
for(long i = 0 ; i < indexes.LongLength ; i++)
argument += indexes[i] + ", ";
argument = argument.Substring(0, argument.Length-2);
Console.WriteLine("alfaArgument["+argument+"] = " + alfaArgument.GetValue(indexes));
indexes[alfaArgument.Rank-1] ++;
for(long i = indexes.LongLength-1 ; i > -1 ; i--)
{
if(indexes[i] >= alfaArgument.GetLongLength((int)i))
{
indexes[i] = 0;
if (i > 0)
indexes[i-1] ++;
else
return;
}
}
}
I hope you understand...because is a rough world out there...
|
|
|
|
|
Hi,
New to refelection, I'm doing a GetMethod call on an overloaded method and I get an Ambiguous Match exception.
The method has the same name as another method (overloaded).
How can I cal getMethod so this exception is not generated on overloaded methods?
Thanks,
PhrankBooth
|
|
|
|
|
Use any of the overloads for the GetMethod call. You'll notice that there are several GetMethod functions: GetMethod(string), GetMethod(string, Type[]), and so on. The ambiguouse match exception is being thrown because the method you're trying to retrieve has overloads as well. For instance, let's say you're trying to retrieve the SayHello function:
void SayHello(string message)
{
}
void SayHello(string message, bool waveHandAsFriendlyGesture)
{
}
So, you want to retrieve the SayHello method. Let's pretend you want to retrieve the overloaded method that takes both a string message and a bool waveHand. Currently, you're trying to access it like this:
theType.GetMethod("SayHello");
To prevent this error from occuring, use the GetMethod overload that takes a type array, allowing you to specify the types of the arguments:
theType.GetMethod("SayHello", new Type[] { typeof(string), typeof(bool) });
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
OK, I get it. But it follows from this that I would then have to create special cases for each overloaded method, correct?
Thank you,
PhrankBooth
|
|
|
|
|
If you've got overloads, then you have to let the CLR know which particular overload you're trying to get at, so yes, I believe you'll need a special case for each overload.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
I know how to search for text in a an XML file and display it within a combobox. However, how do I put TWO different sets of data within an XML file and have TWO combobox's populated by the separates sets of data? Thanks.
Dizzle
|
|
|
|
|
That's a very ambiguous question. Are you having difficulty reading the 2 sets of data in the single XML file? That question can only be answered if one is to understand the schema of the XML file. You'd basically have to read certain parts of the xml file and store them seperately.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
I only have preliminary data within the XML file. How do I read only certain parts of the XML file? How do I indicate the different parts and how do I get C# to to recognize that? Thanks for your help.
Dizzle
|
|
|
|
|
I have this:
System.Data.DataSet ds=new DataSet();
ds.ReadXml("Preconditions.xml");
for(int i = 0; i < ds.Tables.Count - 1; i++)
{
this.comboBox1.Items.Add(ds.Tables[i].TableName);
}
HOwever, it only populates the combobox with tag names. How can I differentiate between the data within the XML file?
DIZZLE
|
|
|
|
|
Rather than reading the XML into a DataSet, why not just read it yourself using System.Xml.XmlReader? You can iterate through whatever pieces of the document you'd like, thus giving you full control over the data.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
Hi
I have a requirement in Curves and angels. I have drawn a line and I will draw a line which is 45 degrees downwrds from the first line and now I would like to draw an arc which meets the 2 points of the second line and the user can change the angle of the second line. From that arc he has to draw one more line of some length (user specifcation) and draws one more line which has an arc bulging outside this arc again is based on the angle specified by the user.
Plz if any one who know the solution help.
Advance Thanks to all.
Regards
Suresh
|
|
|
|
|
Look into the System.Drawing.Graphics class, there are many methods there that should help you. Addition APIs are available in the System.Drawing.Drawing2d namespace.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
Hi,
I did not get what I was expected plz do help if any one have the solution.
|
|
|
|
|
I have designed a login control that requires a component msrdp.ocx to use a remote server.
this gives my customers trouble because when security settings are on
medium/high it gives a small bar at the top of their screen which they
never see.
So I thought to develop a control in visualc# with a button to load this com clientside which is loaded and hidden.
On page load I want to check clientside if this object already exists
or is running on their server.
If it is login control.visible = true while the load control is hidden.
If it isnt present show load control which on button click should
upload or should i say download to client server this component.
Or better still if I can just load/instanciate it anyways onto the client server on pageload.
I've been at it for weeks and fear i may get the sack if i cant carry
this task out pls help if you have the time.
any assistance would be highly appreciated!
If this dosn't make sense pls visit www.webex.com and join a live demo!
from this you may get the idea!
Kind Regards
Femi Ojemuyiwa BSc.
|
|
|
|
|
I am trying to copy a metafile into a Word document, and then set its location on the page. It pastes it alright, but I get an error that the "object is not valid" when I try to change the location. I think I am not properly getting ahold of the shape that has been pasted, but I do not know where the problem is. Here is the code:
object oEnd = "\\endofdoc";
oRange = oDoc.Bookmarks.Item(ref oEnd).Range;
object pasteDataType = Word.WdPasteDataType.wdPasteMetafilePicture;
oRange.PasteSpecial(ref oMissing,ref oFalse,ref oMissing, ref oFalse,
ref pasteDataType, ref oMissing, ref oMissing);
oRange = oWord.Selection.Range;
oShapeRange = oRange.ShapeRange;
oShapeRange.Left = xLoc;
oShapeRange.Top = yLoc;
oShapeRange.Width = xSize;
oShapeRange.Height = ySize;
|
|
|
|
|
I'm trying to validate a TextBox for a floating point or int value ONLY.
Keep getting a compiler error of "Unrecognized Escape Seq".
Regex theRegex = new Regex("[-+]?([0-9]*\.)?[0-9]+ ");
A) A quicker better way to validate?
B) Where is the code incorrect?
thanks
|
|
|
|
|
The '\' right after the * character is what is causing the compiler to baulk. Either escape it ('\\') or make the string verbatim by prefixing the @ symbol (Regex theRegex = new Regex(@"[-+]?([0-9]*\.)?[0-9]+ "); )
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
A.
Specify the RegexOptions.Compiled flag when you create the object if you plan to use it more than once. It takes longer to create the object, but it runs faster.
B.
As regular expressions and C# strings use the same escape character, you have to escape the escape character. Use \\ to put \ in the string.
Also, you are missing the ^ and @ to specify the beginning and end of the string. Without them, any string containing a number will be valid, for an example the string "We have 200 horses.".
You have an extra space at the end of the pattern. Remove that.
[0-9] can also be written as \d.
Regex theRegex = new Regex("^[-+]?(\\d*\\.)?\\d+@");
Or you can use an @-quoted string:
Regex theRegex = new Regex(@"^[-+]?(\d*\.)?\d+@");
---
b { font-weight: normal; }
|
|
|
|