|
I guess that depends on how you're going to use them and if the structs are the same type. The IComparer interface is what you'd want to use if you didn't have control of the structs and you were trying to sort them in a list (for example). You could also implement the IComparable interface on the struct if you have control over them.
|
|
|
|
|
You should not use Equals if you want to compare for true equality, because Equals only checks if the compared values refer to the same instance. To determine true equality of value you have to compare the fields. See Richter for further information. The base implementation actually compares for identity, not equality.
|
|
|
|
|
Hi,
I have a table displayed in a datagrid.
If I select a cell, that row has to be populated in the text boxes that I have.
I am unable to refer to the individual fields in the row, of the cell that I clicked.
For EG: If i select any cell in row 10 all the columns in row 10 has to be populated in the text boxes that I have.
Can you please tell me how to refer to the cells in the row that I have selected.
An example code will be very very helpful.
Thanks,Arun
|
|
|
|
|
Try something like this:
DataGridCell dgCell = dataGrid.CurrentCell;
textBox.Text = dataGrid[dgCell.RowNumber, dgCell.ColumnNumber].ToString();
|
|
|
|
|
Hi,
I am trying to find out if there is some function to validate whether a user entered an integer. All suggestions welcome. Thanks.
|
|
|
|
|
Entered an integer into what? A web for then I would suggest javascript validation isNumber (or is it isNumeric I really don't remember) or even the regular expressions.
If it is server side just TryParse.Int32. Also, various styles of input text boxes exist which can automagically restrict input.
File Not Found
|
|
|
|
|
Here are a couple of ideas:
1. You could mask the input and only allow digits:
protected override void OnKeyPress(KeyPressEventArgs e)
{
base.OnKeyPress(e);
if (char.IsDigit(e.KeyChar) == false)
{
MessageBox.Show("Invalid Input...");
}
...
}
Of course you would also have to handle the user entering text without pressing a key (a paste operation for example).
2. You can attempt to convert the value when the user is finished:
protected override void OnLostFocus(EventArgs e)
{
base.OnLostFocus(e);
int number;
bool isNumber = int32.TryParse(textbox1.Text, out number);
if(isNumber == true)
// Do something
else
MessageBox.Show("Invalid Input...");
...
}
}
Ian
|
|
|
|
|
When testing one of my programs i got a Loader Lock Message from VIsual Studio 2005:
LoaderLock was detected
Message: Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.
I did some testing and it occurs whenever I press a key on a program i am testing, even if there is only a form and nothing else. How should I fix this problem? I need this fixed to test my program. Thanks.
|
|
|
|
|
The loader lock detection isn't an actual exception; it's a Visual Studio "debugging assistant" that helps you track down bad practices, leaks, and other workin's of the devil.
First of all, make sure this is valid: are you doing any unmanaged interop during initialization? If so, this error may be valid and you should fix it.
If this isn't a valid error, fortunately for this scenario, you can disable this debugging assistant: Debug->Exceptions->Managed Debugging Assistants->Loader Lock. Uncheck the "thrown" box, and you won't see this error any more.
|
|
|
|
|
Thanks.
I'm definately not doing any unmanaged interop, I'm using the code the designer made for me, and it has an error with its own code. So I will turn it off.
|
|
|
|
|
HI
I wanted an anti-virus software to which i can provide files and get resuts programatically.
Any AV software that give SDKs or some sort of API's
Thank you!
|
|
|
|
|
Is open source.
File Not Found
|
|
|
|
|
A lot of them provide this, but you usually have to purchase it. I'm not sure if there are any open source av scanners, and, if there are, what their effectiveness is.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
I have a text file that I want to reference in my code via a relative file path versus an absolute one. How would I go about doing this?
For instance: A text file named "address01.txt".
Also, is this the best way to reference a text file during runtime (or installed on a machine) or should I make it an embedded reference?
Thank you.
|
|
|
|
|
Relative file paths are relative to the exe. Unfortunately, you should not have write access to that directory. Instead you should copy a location on the first run to either System.Windows.Forms.Application.CommonAppDataPath or System.Windows.Forms.Application.LocalUserAppDataPath.
Put it in as an embedded resource and then copy to the above mentioned paths if you need to write to it.
File Not Found
|
|
|
|
|
Hello,
I am extremely new to Visual Studio 2005 and I'm trying to utilize report viewer to display a report of data accessed at runtime. I'm finding it difficult in getting the data to display in the report viewer.
Does anyone have any advice or suggestions? The article at http://www.codeproject.com/useritems/reportdisplay.asp?df=100&forumid=285487&fr=26 I have tried and unfortunately I cannot get my report to display anything.
I'm trying to run a stored procedure server side based on parameters entered in the program which would then return a dataset to display in a report but I seem to have trouble being able to do this.
Is there a better tutorial on the net that can assist me?
Thanks in advance.
|
|
|
|
|
Hi,
I am creating a Shell Extension to appear in "My Computer" which is all working OK apart from when I click on an item (Handled by the OS, not me own IShellView) I get the following message:
"This page has an unspecified potential security flaw. Would you like to continue?"
Does anyone know what causes this error?
Thanks,
Dan
|
|
|
|
|
I refer you to KB article 323034[^].
Personally I wouldn't try to develop a shell extension in C#. Only one version of the CLR can load into a given process, and the first version to load wins. When loading classes through COM Interop, by default, the most recent version of the CLR is loaded. Problems can occur if you have multiple plug-ins which need different CLR versions.
|
|
|
|
|
Thanks for the link but I don't think that is related as it's not a web page and I'm not calling showModal() ot any functions like that. The only thing I would be calling is Process.Start but the error happens before I get there.
Also, I realise the issues with using C# to develop shell extensions but this is just a prototype which will eventually be re-written in C++ once we have a design (I am not a C++ developer so I won't be working on that)
|
|
|
|
|
Dear Friends:
How can I change a file's or directory's name programmatically? I could not find such a method in File and Directory Class that file or directory names can be changed programmatically. Only the Move or Copy method is available. If the file's size is big, the copy or move action takes considerable time. Thanks!
Gary
Sheng
|
|
|
|
|
File.Move should not take any time if the move is to the same disk (i.e. a rename operation). Internally, it calls Windows' MoveFile function. There is no rename function in the Windows API itself.
It's possible that an implementation of the Windows file sharing MoveFile command isn't capable of doing this, but that would affect all file rename operations on that server.
|
|
|
|
|
Mike:
Thanks for your help!
Sheng
|
|
|
|
|
You actually have to use the Move method for this. In the source field, you give it the fully qualified path for the file you're renaming. In the destination parameter, you give it the same fully qualified path, but with the filename changed to the name you want it to be.
File.Move(@"C:\test\testfile.txt", @"C:\test\testfile2.dat")
If you give it fully qualified names for both parameters, but on different Shares or Drive Letters, then a Copy operation will take place, followed by a Delete of the original file.
File.Move(@"C:\test\testfile.txt", @"D:\test\testfile2.dat")
The same is true if you just give the filename as a destination parameter. This is because if only a filename is given, whatever the current directory is is assumed to be the destination path
Current directory is: C:\Program Files\MyApplication\
File.Move(@"D:\test\testfile.txt", @"testfile2.dat")
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave:
Your solution converges with Mike's. I think this is the correct way of renaming a file or directory. Thanks!
Sheng
|
|
|
|
|
Hello,
I'm trying to use sobe web methods in my windows service but I'm having a problem with the ones that need authentication.
The webservice has a method named "Authentication" but it returns always false. I set the cookiecontainer before calling this method, besides the cookiecontainer after the method is called it raises his count to 1. The result of the authentication is false. Which doesn't allow me to call other web methods that require authentication.
When i try exactly the same code with an aspx page, it works fine.
Does authentication has to always run in a browser?
How can i use in my windows service?
Code:
PalviewWS.Palview palview = new global::PWYDService.PalviewWS.Palview();
palview.CookieContainer = System.Net.CookieContainer();
bool result = palview.Authentication("xxx", "xxx");
Thanks in advance!
|
|
|
|