|
Ok, it works like a charm
Thanks a lot
There is no spoon.
|
|
|
|
|
This is a BigEndian LittleEndian problem
This means that your system writes a hexadecimal number in the right-left order or left-right...
I guarantee you that if your system writes the number in that order, when it will attempt to read the number, te result will be the correct one...
But, if you just want to format in that way your data into the file, the simplest way is to split the number into bytes, write them, spend some time, read the bytes back and build your numbers ...
I hope you understand...because is a rough world out there...
|
|
|
|
|
And how to write an Int32 or Int16 in a Big Edian format?
There is no spoon.
-- modified at 16:25 Thursday 1st September, 2005
|
|
|
|
|
Here is an example on how to split a Int32 into bytes :
UInt32 myNumber = (UInt32)0xfefdfcfb;
byte b4 = Convert.ToByte(myNumber/(65536*256));
myNumber -= ((UInt32)b4) * (65536*256);
byte b3 = Convert.ToByte(myNumber/65536);
myNumber -= ((UInt32)b3) * 65536;
byte b2 = Convert.ToByte(myNumber/256);
myNumber -= ((UInt32)b2) * 256;
byte b1 = Convert.ToByte(myNumber);
Here b1 is LSB and b2 is MSB, meaning that myNumber is 0xb4b3b2b1
I hope we understand...because is a rough world out there...
|
|
|
|
|
Not sure if it's the most efficient but anding the int with masks to extract each byte, bitwise shifting them until the desired byte is in the lower 8 bits, and converting the result into an int8 should work.
This code will extract the 3rd byte of i and assign it to b;
uint i = 0xAABBCCDD;
uint j = i & 0x00FF0000;
j = j >> 16;
byte b = (byte)j;
|
|
|
|
|
What's the most direct way to validate the text in a textbox?
If the text entered is NOT a number an "Invalid Entry" MessageBox will pop up.
How to code (more or less)? thanks....
|
|
|
|
|
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
|
|
|
|