|
hey guys..i want to open a new form inside my MainForm when i click datagridview cells.. to do that i wrote these
dtyfrm = new DetayForm();
dtyfrm.MdiParent = this;
dtyfrm.Show();
but when i wrote this my Up-Down buttons dont work on the datagridview and when i delete thse block and try it they work
my KeyDown even is like that
so what is wrong now ?
|
|
|
|
|
erdinc27 wrote: so what is wrong now ?
1. Your code is all commented out so there is nothing to do.
2. If you uncomment it you have try catch blocks that ignore any caught exceptions.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
try
{
if ((e.KeyCode == Keys.Down))
MessageBox.Show(" ");
try
{
if ((e.KeyCode == Keys.Up))
MessageBox.Show(" ");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
hey friend thanks for reply...i uncommented my codes but it doesnt give any error and the up-down buttons
and it doesnt move up-down
|
|
|
|
|
What the ....??
First, this code cannot possibly throw an exception, so why even bother with the Try/Catch blocks?? Remove them...
if (e.KeyCode == Keys.Down)
MessageBox.Show(@"Down");
if (e.KeyCode == Keys.Up)
MessageBox.Show(@"Up");
|
|
|
|
|
I was unable to respond earlier due to the move. However, as Dave says, why on earth are you using try catch around such simple code? No, don't answer that. I am still not sure why you think it necessary to capture the key events, since the gridview will do most of the work for you. Perhaps you could explain why you are doing it this way.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Trivi: You did'nt forget to += your KeyDown handler or some code removed it later?
As a last way out install a WndProc like
protected override WndProc( ref Message m )
{
// Do whatever here...
base.WndProc( ref m ); // May or may not need this call.
// ...or here.
}
I'm not updated on how messages are handled/filted for your grid type, byt this can be a last way out giving you a chance to milk msg's before they go in. The right word for this method should have been PreTranslateMessage(MSG*) like in the MFC days.
Michael Mogensen
|
|
|
|
|
hey guys
thanks for your help..the things i learnt are very usefull really
|
|
|
|
|
hi all
in neural networks algo of face detection a term is used a lot " training neural network". what does it mean? and a file is used with extension of NNCP which is loaded first. as for as i know that file contains different patterns of faces. i wana implement the neural network algorithm but i don't understand how to train neural network and how to make this NNCp file which contains different face paterens.
any suggestions links will be appreciated.
thanks
|
|
|
|
|
Please stop multi posting the same question.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
This is where you EARN your passing grade, and your degree, by doing your own research.
If this topic is something you picked, then you bit off more than you can chew before the end of the class. If it was assigned to you, then you've already been presented the materials during the class to get the job done.
|
|
|
|
|
yes sir i started my own research now.
|
|
|
|
|
If you spent as much time researching NNWs as you have posting here and here[^] you'd know at least how to train one.
Really, you need to look for a new project, you just won't cope with the one you have.
|
|
|
|
|
i understood the Neural Networks now by my self.
|
|
|
|
|
Except you don't: you don't even know what training a NNW is, this falls under the category "Basics".
|
|
|
|
|
I suggest you go and talk to Prof. S.M. Aqil Burney, you can get his e-mail here University of Karachi CS Faculty[^] he seems to be the expert at your Uni. I also suggest you stop spamming the lounge.
|
|
|
|
|
|
inayathussaintoori wrote: who are you
He is the one giving you good advise.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
Read my profile[^] on the code project, it's all there.
|
|
|
|
|
I have a dialog where I need to return a result. The result can be either a "standard class defined value" (an enum) or a user defined value (an int).
So I end up with something like:
enum SomeEnum
{
Val1 = 1,
Val2 = 2,
Val3 = 4,
Custom = 8
}
public SomeEnum Result
{
get
{
...
}
}
public int UserResult
{
get
{
...
}
}
The idea here is that if Result is Custom, they call UserResult to get the custom value. I'm not really keen on that idea because they have to look at 2 properties.
I could cast Result to an int and return it that way, but that idea, I'm not really happy with either because they'll be using the built in values 75% of the time, so having the code littered with casts isn't that great.
I could return (or accept) both as object, but that'd be a lot of "if (Result is ...)" checks.
On the drive in to work, I thought about having the user derive an enum from the built in enum and extend it, but apperently C# doesn't allow that .
Any other ideas?
|
|
|
|
|
Two options off the top of my head:
1) Return a struct containing an enum and an int. If the enum is custom, process the int.
2) Just return the enum, but consider custom to be the "else" case... It may be bad practice, but an enum can contain integer values that aren't listed. So if the user picks custom, return the UserResult cast to an enum.
|
|
|
|
|
I got another idea too... instead of using an enum, I can use consts...
public class SomeEnum
{
public static readonly int Val1 = 1;
public static readonly int Val2 = 2;
}
this way, I can just return an int for both cases and not have to worry about typecasting or exceptions from something like enum.ToString() when it contains an unknown value.
I guess this is a little better then having the 2 properties... and eliminates checking for the custom type.
|
|
|
|
|
Hi,
What about this piece of code ?
public class MyDialog : Form
{
public SomeEnum Result { get; private set; }
public int UserResult { get; private set; }
}
private void btnChoose_Click(object sender, EventArgs e)
{
using (MyDialog dlg = new MyDialog())
{
(if (dlg.ShowDialog() == DialogResult.OK)
{
if (dlg.Result == SomeEnum.Custom)
{
}
else
{
}
}
}
}
Thus, your dialog should only care to set both its properties according to your logic. Only your main form should care about values and decide what to do next, according to your particular logic.
And, if you want to store the final value in a variable in order to use it later, i'm afraid you won't have another choice than storing it to an int and doing casts from/to your SomeEnum type.
Or, you could hold two variables (one of int type and another one of SomeEnum type) and repeat your logic everytime you have to decide something from them (this part could be encapsulated in a small utility class that would hold a few methods implementing the logic).
I can't think of other solutions since I don't know what are your actual requirements/logic.
Hope this helps.
Regards.
|
|
|
|
|
if your int result needs its full range, I see no way other than having two results, as you stated.
if OTOH part of the int range will not be needed, then you could map your special values in there; the easiest would be when the int result only has positive values, then you could do:
const int val1=-1;
const int val2=-2;
const int val3=-3;
int res=MyFunction(...);
if (res>=0) log ("custom value = "+result);
or
switch (res) {
case val1:
log("val1");
break;
case val2:
log("val2");
break;
case val3:
log("val3");
break;
default:
log ("custom value = "+result);
break;
}
|
|
|
|
|
Yeah, I'm thinking "simulating an enum with const ints" might be the best solution since there won't be typecasts and/or special case checks for the custom values.
|
|
|
|
|
Would something like this work?
[Flags]
enum BarEnum
{
none = 0,
Bar1 = 1,
Bar2 = 2,
Bar3 = 4,
Custom = 8
}
static void Main(string[] args)
{
BarEnum e = Foo();
if( (e & BarEnum.Custom) == BarEnum.Custom)
{
int result = (int)(e ^ BarEnum.Custom);
}
}
private static BarEnum Foo()
{
return BarEnum.Custom + 80;
}
I know the language. I've read a book. - _Madmatt
|
|
|
|