|
int f = 256;
string s = f.ToString("0000");
And I swallow a small raisin.
|
|
|
|
|
I have a form with a menubar and a tab control. Each tab has a set of buttons which inlcude Close and Detach. Once I hit either of these buttons, the code works as expected. However after that my application refuses to exit.
The button I've played with the most, Close, has relatively simple code. It iterates through the COntrols on th emain form, finds the tab page it's looking for and then removes it.
I've traced my code and I know that Application.Exit() is being called but it's not forcing Application.Run to return. What could be going wrong?
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
There is a bug in the WinForms code that causes forms to refuse to close if their ActiveControl (ie the control that has focus) is removed. I would expect that this is what you are experiencing.
There are a number of workarounds available on the web and newsgroups (time for google[^]!). The easiest I've found is to manually shift focus to an off-screen, permanent control before you remove the other control.
--
Russell Morris
"Have you gone mad Frink? Put down that science pole!"
|
|
|
|
|
Ouch. Well the control that I am removing is just a tab page in the tab control. I'll just switch focus to another tab page and then remove the one I want.
Sh*tty bug. Hope they will fix it soon.
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
I have an Explorer extension that implements the IContextMenu interface. It all compiles fine in vc6 but if I open and hence convert it in vc7 (.net) it tells me that interface hasn't been defined. In my class file I can right click on the word IContextMenu and go to definition and life is good. all win32 defines are correct. Would there be a problem with the SDK if it was installed before .Net. Maybe I'll check the SDK update...
|
|
|
|
|
From what I read, you are not using C# (C# forum).
-IContextMenu is defined in ShlObj.h which is not a default header automatically included by vc.
-IID_IContextMenu is defined in ShlGuid.h
-You must link with either uuid.lib or shell32.lib
And I swallow a small raisin.
|
|
|
|
|
hi,
i'm designing an exception for my program and have the following problem. i want an additional constructor, which gets an int as paramter, builds a string out of it and calls the base-classes constructor with a string.
something like
class MyException : ApplicationExcpetion
{
...
public MyException(int errorCode)
{
string message;
switch(errorCode)
{
case
default: message="unkown errorcode"; break;
}
base(message);
}
}
but C# tells me: "Use of keyword base is not valid in this context"
i'm stuck. anyone any idea?
thx!
:wq
|
|
|
|
|
You can only call the base constructor like the following.
<br />
class MyException: ApplicationException<br />
{<br />
pubilc MyException(int errorcode) : base ( MyException.GetErrorString(errorcode) ) {<br />
}<br />
}<br />
The base constructor can only be called in that location.
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
yeah, with GetErrorString being a static function is does work - thanks a lot!
sometimes it's like a blocking in your head, when you're coding all day long...
:wq
|
|
|
|
|
I would also prefer to be able to delay the base construction. Look at my case.
class MyException: ApplicationException
{
int errorcode;
pubilc MyException() {
errorcode = GetErrorCode();
base ( MyException.GetErrorString(errorcode) );
}
}
Now I wouldnt have to call the GetErrorCode() function everytime when i need to throw it
Maybe there is a way to pre-initialise some variables...
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
|
Hi all,
Does anyone know how to determine which node of a treeview control the mouse pointer is over when a drop occurs? Maybe I am asking the wrong question: I want to allow the user to drag something from a listbox control onto a particular node of a tree view so that the dragged object can be added as a child node.
Any thoughts?
Thanks,
Bill
|
|
|
|
|
//Gets the point relative to the treeview
Point dragPoint = tv.PointToClient( new Point(e.X, e.Y) );
//Gets the treenode
TreeNode target = tv.GetNodeAt( dragPoint.X, dragPoint.Y );
|
|
|
|
|
It's always so simple once you know what the answer is.
Thanks.
|
|
|
|
|
I have 3 functions. All 3 the functions are identical except for a type and a function.
Now i want to combined all three into one. I assume it would be,
void CombinedFunction(Type type, SomeHandler function);
No the problem i have is, is that not all of the functions share the same parameters. All 3 have common parameters, but one has 2 extra parameters.
Would i HAVE to overload that function to pass any of the functions as a parameter.
Hope that makes sense
Thanx
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
|
O ya I solved this, noted though far down the optional parameter thread
The easier, better way was just to overload the function as the 2 optional parameters had fixed values when used in that context.
And...the function works beautifully
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
I am using regex (regular expressions) in my C# application. I am pulling out the first name like this...
Regex regName = new Regex( @"(?<Last>\S+), (?<First>\S+)" );
Match pMatch = regName.Match( "Doe, John" );
Text strFirst = pMatch.Groups[ "First" ].Value;
Question: If the user changes the name to 'Jane', how can I use regular expressions to replace the first name?
If strFirst = "Jane", then I want a new string to be "Doe, Jane".
Thanks!!
|
|
|
|
|
You'll want to use Regex.Replace, and then create a replacement string. Something like:
Regex regName = new Regex( @"(?<last>S+), (?<first>S+)");
regName.Replace (string, @"\k<last>, Jane");
The \k refers to whatever matched the "Last" capture.
If you're playing with regex, you might like this utility:
http://www.gotdotnet.com/userarea/keywordsrch.aspx?keyword=regular%20expression%20workbench
|
|
|
|
|
Eric, there's a link tool down at the bottom. Very handy. Just highlight and click link[^]
http://www.gotdotnet.com/userarea/keywordsrch.aspx?keyword=regular%20expression%20workbench [^]
David Stone
But Clinton wasn't a predictable, boring, aging, lying, eloquent, maintainer-of-the-status-quo. He was a predictable, boring-but-trying-to-look-hip, aging-and-fat-but-seemingly-oblivious-to-it, lying-but-in-sadly-blatant-ways, not-eloquent-but-trying-to-make-up-for-it-by-talking-even-more, bringer-in-of-scary-and-potentially-dangerous-new-policies. And there was also Al Gore. It just wasn't *right*.
Shog9
|
|
|
|
|
Is it safe to assume that anytime you do some sort of COM Interop with a dll that wasn't written using the .NET Framework that the method call needs to be prefixed with the unsafe marker, or is this only needed when the method deals with pointers that are outside the bounds of .NET to handle directly?
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
unsafe int SomeFunction(....);
Nick Parker
|
|
|
|
|
U only have to specify unsafe if the compiler complains
No, but really unsafe only needs to be declared if you are using pointer notation in C# ( *, &, -> ). It is recommneded though (as far as I am aware) to use the Marshalling class as far as possible, else they wouldnt have called it "unsafe".
Cheers
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
leppie wrote:
U only have to specify unsafe if the compiler complains
Somehow I believe more people than you think use this method.
Nick Parker
|
|
|
|
|
Is it possible to make a method to have options parameters, without defining the function for each valid configuration?
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
Not sure, however you could always overload the function.
Nick Parker
|
|
|
|