|
Hi,
IMO, assign a unique id or number to each picture box.
declare two variables namely StartPB, and CurrentPB.
in the mouse down event, get the id of the StartPB and in mouse_over event set the CurrentPB with the current id.
now just use general comparison to arrive at your logic....
say you have selcted the nth picture box
then a
b
c
g h i n j k l
d
e
f
you can easily create your required functionality by some simple mathematics with the selectPB and CurrentPB values......
Good Luck and leave a reply if you find some better solution.....
Have a Happy Coding.....
|
|
|
|
|
Hi all,
Can you please help me out or advice on how to solve the following problem.
I'm reading files line by line from a folder and I'm saving the file content into the database. Now, my problem is that some of the lines from the file are the same. I can read the first line and when I reach the other line that has the same name as that first line my 'line' variable becomes empty and nothing got saved in the database (for only those lines that are the same). I need to save all the content of the file into the database, even those lines that are the same (numbering and heading).
my file looks like this (taken some content of the file)
1. This Report Concerns :
an individual
2. Surname :
Nkwanyana
3. First Name :
Nonti
4. Other Initials :
Z
5. Identifying number :
7200506586321
6. Type of Identifier :
_ID Book
7. Country of Residence :
South Africa
1. Transaction was conducted by :
the person referred to in Part D
2. Surname :
Phungo
3. First Name :
Hendrica
4. Other Initials :
M
5. Identifying number :
8695421345789
6. Type of Identifier :
ID book
7. Is there a photograph or other image of the person available?
NO
my code looks like:
if (line != null && line.Contains("2. Surname :"))
{
line = reader.ReadLine();
Surname = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("3. First Name :"))
{
line = reader.ReadLine();
FirstName = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("4. Other Initials :"))
{
line = reader.ReadLine();
OtherInitials = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("5. Identifying number :"))
{
line = reader.ReadLine();
IdentifyingNumber = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("6. Type of Identifier :"))
{
line = reader.ReadLine();
TypeOfIdentifier = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("7. Country of Residence :"))
{
line = reader.ReadLine();
CountryOfResidence = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("2. Surname :"))
{
line = reader.ReadLine();
SecSurname = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("3. First Name :"))
{
line = reader.ReadLine();
SecFirstName = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("4. Other Initials :"))
{
line = reader.ReadLine();
SecOtherInitials = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("5. Identifying number :"))
{
line = reader.ReadLine();
SecIdentifyingNumber = line;
line = reader.ReadLine();
}
if (line != null && line.Contains("6. Type of Identifier :"))
{
line = reader.ReadLine();
SecTypeOfIdentifier = line;
line = reader.ReadLine();
}
Will really appreciate your help.
Thanks.
|
|
|
|
|
If you got a problem with the database it would be helpful if we can see your database-access code...
I guess your line is empty because you are reading the empty line between each record.
I would suggest to refactor your code to read it more like this (pseudo-code):
while( (line = reader.ReadLine()) != null) {
if(line.startsWith("1.") || (line.startsWith("2.") ... {
string sValue = reader.ReadLine();
this.SetValue(line, sValue, oOutput);
}
}
public void SetValue(string sDescriptive, string sValue, MyClass oOutput) {
if(sDescriptive.Contains("2. Surname :")) {
oOutput.Surname = sValue;
} ...
}
Hope this gives you an idea...
Regards
Sebastian
|
|
|
|
|
I don't think the problem is with the database but here is my database code:
cmd.Parameters.Add("@ThisReportConcerns", SqlDbType.VarChar, 50).Value = ReportConcerns;
cmd.Parameters.Add("@Surname", SqlDbType.NVarChar, 50).Value = Surname;
cmd.Parameters.Add("@FirstName", SqlDbType.NVarChar, 50).Value = FirstName;
cmd.Parameters.Add("@OtherInitials", SqlDbType.NVarChar, 50).Value = OtherInitials;
cmd.Parameters.Add("@IdentifyingNumber", SqlDbType.NVarChar, 50).Value = IdentifyingNumber;
cmd.Parameters.Add("@TypeOfIdentifier", SqlDbType.NVarChar, 50).Value = TypeOfIdentifier;
cmd.Parameters.Add("@CountryOfResidence", SqlDbType.NVarChar, 50).Value = CountryOfResidence;
cmd.Parameters.Add("@Surname2", SqlDbType.NVarChar, 50).Value = SecSurname;
cmd.Parameters.Add("@FirstName2", SqlDbType.NVarChar, 50).Value = SecFirstName;
cmd.Parameters.Add("@OtherInitials2", SqlDbType.NVarChar, 50).Value = SecOtherInitials;
cmd.Parameters.Add("@IdentifyingNumber3", SqlDbType.NVarChar, 50).Value = SecIdentifyingNumber;
cmd.Parameters.Add("@TypeOfIdentifier2", SqlDbType.NVarChar, 50).Value = SecTypeOfIdentifier;
The problem is that the file contains lines that has the same numbering and heading, e.g:
2. Surname:
Mkhwanyana
3. First Name:
Nonti
2. Surname:
Mbambo
3. First Name:
Hendrica
etc.
|
|
|
|
|
Are there empty lines between the values? I think the lines are empty because when you find the first surname you place the cursor (line) on an empty line so that no one of the following if-statements will be fulfilled. Use a loop to read each line according to my suggestion...
Did you refactored your code like I mentioned (reading in a loop)? Try to debug your code step-by-step.
Regards
Sebastian
|
|
|
|
|
Yes, I am reading within the while loop
while ((line = reader.ReadLine()) != null)
{
//read lines from the file
}
|
|
|
|
|
Hi
thanks a lot for your advice. I decided to use a flag in order for my program to read the right line at the right time and now its saving the right values into the database. I really appreciate your help.
Thanks.
|
|
|
|
|
Hi
how I can run any .exe file through WebService that I build ?
thank's in advance
|
|
|
|
|
Have a look at the System.Diagnostics.Process class...
|
|
|
|
|
I try this:
[WebMethod]
public void GO()
{
System.Diagnostics.Process H = new Process();
H.StartInfo.FileName = @"d:\siw.exe";
H.Start();
H.WaitForExit();
}
but still not working
whay ?
|
|
|
|
|
Okay, so what is not working exactly? Do you get an error message?
Btw, calling an exe from an asp.net application can be difficult because of security issues. Check whether the aspnet-process has the rights to see and execute your exe-file.
|
|
|
|
|
Hi there,
Ocassionally, due to malware infection, it is seen that some of the infected or suspicious files or folders can be neither deleted nor renamed and when tried to do so, a messagebox is display something like this: "The file/directory cannot be deleted because it is in use by another program or whatsoever". In such case, we have two options, either format the drive containing the file or continue with it.
However, let me directly come to the point. I have written a program which will create a directory with the following code:
{
System.IO.Directory.CreateDirectory("c:/myfolder");
}
With the above code, I have created a folder "myfolder" in the c: drive. But, this folder can be easily deleted. I want to know that how can I create a process or program associated with it running continuously, such that whenever the user tries to delete the folder, the messageBox "The file/directory cannot be deleted because it is in use by another program" is displayed and the user fails to delete it?
Help me and I assure that your help will be appreciated,
Thanx..... and sorry for my poor english (I am trying to improve),
Rajdeep.NET
|
|
|
|
|
Why you want to do that? What happens if user deleted the directory?
|
|
|
|
|
Well, you could create a file within this directory. Open the file with a stream and let this stream open. This will block the file (and directory) as long as your app is running. If you put the code for this in a windows service the app will run as long as the pc...
Regards
Sebastian
P.S.: By the way, what kind of app are you trying to build?
|
|
|
|
|
Actually,
I am trying to understand the way in which a worm or a freaky virus works. I am creating a removable tool. Thanx for your help
Love u a lot,
Take care,
Rajdeep.NET
|
|
|
|
|
Be sure to tell us when you release this removal tool, so we know when to not download it
|
|
|
|
|
It's the same thing every program does with an open file. You can't delete a file while it's in use, windows won't let you (Or most any other OS for that matter). In order to delete the file you have to stop the process that's using it. In order to delete a file that a virus is using, you have to unload the virus from memory.
The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.
|
|
|
|
|
I am not at all sure about your reasons for doing this, but if I wanted to I would start out by researching FileStstemWatcher .
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi Experts.
Pls Help Me How To Make Thread Safe Application in C#.NEt ............
Pls Help Me................
Thank u
Dinesh Sharma
|
|
|
|
|
Sharma Dinesh Kumar wrote: To Make Thread Safe Application in C#.NEt ............
Read the tutorials and comeback with specific questions. This[^] will be a good start.
|
|
|
|
|
Pen p = new Pen(Color.Black,PenWidth);
GraphicsPath gp=new GraphicsPath();
gp.AddLine(StartPoint,EndPoint);
gp.Widen(p);//error:outofmemoryException
|
|
|
|
|
This will happen when StartPoint == EndPoint.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
thank your answer ,but incorrectness.
Pen p = new Pen(Color.Black,PenWidth);
GraphicsPath gp=new GraphicsPath();
Point StartPoint=new Point(234,123);
point EndPoint=new Point(567,345);
gp.AddLine(StartPoint,EndPoint);
gp.Widen(p);//error:outofmemoryException
This will also happen when StartPoint != EndPoint .
|
|
|
|
|
That code works for me with no exception. The only way I can generate an exception is if the points are equal.
Is this the actual code you are using? If not, the problem could be elsewhere in your code and not manifesting itself until the Widen call.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
thanks for your answer ,you are right.
|
|
|
|