|
|
Hi,
that class can be used if I set up a connection from within my application. But I need to intercept data from the browser itself, not from within my application....
|
|
|
|
|
Hi All,
I want to write an application, which searches the pdf files based on some keywords. All the pdf files which contains the keywords should be listed.If we double click one of the entries, it should open the pdf in a seperate window( all the keywords should be highlighted). Any idea ?
Thanks for your time
Mahesh Varma
|
|
|
|
|
I 's trying to do one of my school project and I 've a textbox which has multilines true and I was assigning string to the lines[] property. While assigning I 'm getting the error I listed below this program.
Would anybody please help me because I 'm new to this language?
I ' would really appreciate.
Thanks.
Gurvinder
private void cmdSelect_Click(object sender, System.EventArgs e)
{
// string seperated by colons ';'
string info;
info = txtTypeCommand.Text;
string[] GetInput = new string[4];
// define which character is seperating fields
char[] splitter = {','};
int Intval;
GetInput = info.Split(splitter);
if (GetInput.Length > 2)
{
MessageBox.Show("Only '1' Comma is allowed");
return;
}
for(int i = 0; i < GetInput.Length; i++)
{
if(i==0)
cmdArray[RowCommand,i] = Convert.ToInt32(GetInput[i]);
else
cmdArray[RowCommand,i] = Convert.ToInt32(GetInput[i]);
}
txtShowCommand.Lines[RowCommand] = info;
RowCommand += 1;
}
Error!!!
I 'm getting error an Unhandled exception has occured in your application.
Index was outside the bound of the array
|
|
|
|
|
The first thing you should definitely do is figure out exactly which line is causing this exception to be thrown. Debug it and step thru it. Figure out exactly which line is throwing the exception. You could also catch the exception and inspect it inside the catch block (the Exception class contains a full stack trace in it that will tell you exactly which line threw the exception).
I'm almost positive it's the lines that say:
cmdArray[RowCommand,i] = Convert.ToInt32(GetInput[i]);
This appears to be the only place you could get an array out of bounds exception, because the GetInput array will be properly initialized by the Split command (and you're going from 0 to its length, which is perfectly legal). Is this cmdArray set to the Textboxes lines? If you don't know how big he array's going to be, consider using a collection of some sort that will allow you to add things at will.
One other comment...
The array creation in this line:
string [] GetInput = new string[4];
is pretty much not needed. The Split command will return an array, so you could just say:
string [] GetInput;
and let the Split command assign however big the actual array is. There's nothing special basically about initializing it to an array of 4 strings since it will be recreated when you do the Split.
That's about all I can help without seeing the rest of the code, but that should give you a good place to start looking.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Generally very good advice. But there is another line that could cause the error:
txtShowCommand.Lines[RowCommand] = info;
--Colin Mackay--
EuroCPian Spring 2004 Get Together[^]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
|
|
|
|
|
Thanx much David and Colin,
I think Colin is right I 's having problem in .
txtShowCommand.Lines[RowCommand] = info;
when I initialize Lines[] property by clicking [...] button then I don't get this error but neither I get the assignment of info to the line.
Thanks again!!!
Gurvinder
|
|
|
|
|
I got my Winform application to hide from the taskbar but I still see it when I do an ATL-TAB. Is there a way I can hide it from that?
Thanks
Ralph
|
|
|
|
|
Hi,
I am able to rum my application but now when I package it and install, it gives the TypeInitializationException : The type initializer for "Start" threw an exception !
Start is the name of the namespace which has Main.
I was able to install it earlier but I can't seem to think what changed that let to this disaster.
Any clues ?
Thanks,
Paul
|
|
|
|
|
Namespaces are not types, so that couldn't be it. Try to find the real "Start" type.
And when exectly does it give the error?
|
|
|
|
|
Sorry, but Start is the class in which Main is defined. I have put catch blocks everywhere but it doesn't give any more details.
|
|
|
|
|
Does anyone know how to make the print preview dialog open up in a maximized state?
It doesn't have a WindowState property, so I'm not really sure what to do.
Thanks,
Blake
|
|
|
|
|
Set PrintPreviewDialog.DesktopBounds to Screen.PrimaryScreen.WorkingArea .
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I tried that, but the problem is that it doesn't change the state at all, so the maximize button is still available for clicking. Also, it doesn't seem to position the window correctly either. It makes it the correct size, but it doesn't position at the top of the screen.
Is there no possible way to actually change the maximized state and not just the size?
Thanks,
Blake
|
|
|
|
|
That weird about the location. Since Screen.WorkingArea returns a Rectangle - which includes a Point - one would assume that it'd be 0, 0 . You can set PrintPreviewDialog.DesktopLocation to new Point(0, 0) instead.
As far as the state, for some reason PrintPreviewDialog overrides and hides the Form.WindowState property, even though it derives from Form . There might be a valid reason for this, but you could try to set PrintPreviewDialog.WindowState to FormWindowState.Maximized . It won't be visible in the PropertyGrid or code editor, but it's still there (it just gets and sets base.WindowState . Hopefully that works.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I did the WindowState equal to Maximized and its working. Thanks! I just figured since it wasn't in the code editor that it wouldn't work.
Blake
|
|
|
|
|
Heath is right. The WindowState property from Form is still there but hidden by the override. In this case you don't operate on the PrintPreviewDialog but on the base Form . This code seems to do what you want.
<br />
PrintPreviewDialog ppd = null;<br />
try<br />
{<br />
ppd = new PrintPreviewDialog();<br />
Form wind = ppd as Form;<br />
wind.WindowState = FormWindowState.Maximized;<br />
ppd.ShowDialog();<br />
}<br />
finally<br />
{<br />
if(ppd != null)<br />
ppd.Dispose();<br />
}<br />
|
|
|
|
|
What is the quickest way to determine the maximum value in an array. I have a two dimensional array, let's say, SampleArray[17, 127].
For each of the 17 sub-arrays I want to find the maximum of the 127 samples.
Thanks for your help.
|
|
|
|
|
Either use Array.Sort with the 2nd dimension of each 1st dimension and grab the last element, or enumerate (or iterate) through each one, compare values. If the next value is higher than the current, store the the next value. Either way, continue. Both are O(n) operations but unless your array is already sorted, there is no faster algorithm.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello again, Heath!
I used the following code...is this acceptable?
for (int i = 0; i < 17; i++)
{
for (ka = PosCtr; ka < 125; ka++)
{
MaxVal = 0;
MaxVal = Math.Max(MaxVal, AutocorrArray[i, ka]);
}
PeakValueArray[i] = MaxVal;
}
|
|
|
|
|
Shouldn't 125 be 127? I'm not sure what PosCtr is either, but you could probably just hardcode 0 to start at the beginning of the sub-array. You also shouldn't reset MaxVal each time. Just do something like this:
for (int i=0; i < 17; i++)
{
int max = 0;
for (int j=0; j < 127; j++)
max = Math.Max(max, arr[i, j]);
peekValues[i] = max;
} If you reset MaxVal (or max in my example), then the value will always be the max because it's greater than 0. This means that AutocorrArray[i, 126] will be the max value whether or not it is.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
PosCtr is just a counter variable that starts at 31. It starts at 31 and not 0 because I'm not looking at the first eighth of an initial record of length 256.
When I tried your approach I had the following problem:
The max values detected are wrong, and the position is either 122, 123 or 124.
When I used my code:
Whenever there was a sequence of negative numbers followed by a series of positive numbers, the max value recorded is 0
What am I doing wrong?
|
|
|
|
|
The whole point of using Math.Max is to compare the current array value with the previous max value. Whichever one is greater gets stored as the max value and compared to the next value, and so on. My code works under normal circumstances, but it might not work for the constraints you have (like your starting indexes, etc.). You must not reset the max each time, though, otherwise you're comparing the current array value with 0, so the last positive number in your array (or subset - whatever you're comparing) will be stored as the max value. You must remember it as I did in my example so you only store the max. If you want to take negative numbers into account, set the max value initially to Int32.MinValue .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i have an app that defines an abstract base class. i have a dll that has a class which inherits from the base class. the app and the dll reside on the same machine. i want to be able to consume the derived class in the dll from my app by class name. so, my app has function that takes an assembly name and class name. i create the derived class and cast it to the base class. how would i do this?
|
|
|
|
|
See Type.GetType and Activator.CreateInstance for one way. There are many ways to do this. Lets say you have something like this:
App.exe:
public abstract BaseClass {...}
Lib.dll
public MyClass1 : BaseClass {...} In App.exe, you can do something like this:
Type t = Type.GetType("MyClass1, lib.dll");
BaseClass bc = (BaseClass)Activator.CreateInstance(t); If the first statement can't find the assembly (i.e., it's not in the same directory, in the GAC, or configured with a private path or binding path in your App.exe.config file), a TypeLoadException is thrown. If the instance can't be created, a number of exceptions might be thrown depending on what the problem is (see the documentation for the Activator.CreateInstance overloaded method in the .NET Framework SDK for more information).
The only problem is that VS.NET won't let you reference a .exe assembly so you will have to compile this on the command line, which isn't hard. Since MyClass1 derives from BaseClass , which is in a .exe assembly, you can't reference it. The compiler doesn't care, it's just that VS.NET won't let you.
Further, you might consider using a configuration file (.config) so that you can change the types or have a plug-in type system. There are many articles here on CP that cover this, and discuss other ways to load and instantiate a Type by name. Try this search: http://www.codeproject.com/info/search.asp?cats=3&cats=5&searchkw=plugins[^].
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|