|
The Problem is that I cannot use only eventhandler delegate. I am using Infragistics controls and
For example i cannot add same function to Button.Click and
Infragistics.Win.UltraWinEditors.UltraTextEditor.EditorButtonClick because it has type EditorButtonEventHandler.
Maybe there is any way to handle such event using reflection?
|
|
|
|
|
You need at least one event handler for each type of delegate.
The event basically uses a reference to the handler to call it, and if the parameters that the handler accepts does not match the parameters that the event sends, you would mess upp the stack.
Maybe you could add a event handler reference of the wrong type to the event using reflection, but that would probably just crash the application.
---
b { font-weight: normal; }
|
|
|
|
|
Hello,
Is there a way to convert string from a text box to a float?
Thank you
|
|
|
|
|
Convert.ToSingle(stringVal)
Kevin
|
|
|
|
|
float.Parse(myTextBox.Text);
|
|
|
|
|
Unless you specifically need the data type float, use the data type double for floating point operations. The cpu only uses two data types internally, integer and double, any other data type has to be converted before the cpu can do any calculations with them.
double MyValue = double.Parse(MyTextBox.Text);
---
b { font-weight: normal; }
|
|
|
|
|
When i bring up a message box with a yes / no option, how do i make it do different things depending on the reply.
Eg. "Exit" - user
"Are you sure?" - Messagebox with yes / no
"No" - user
continue running the app and dont close.
|
|
|
|
|
|
I've loaded a bitmap in memory, now i would write over (in GDI) text, and rotate it before apply to the bitmap.
how?
|
|
|
|
|
Hi,
See the Graphics.FromImage() method. You can then used the returned Graphics object to draw text on the Bitmap.
Regards,
-Adam.
|
|
|
|
|
I want to find analogue to this function in C#...
I want to draw line on the image with inversed colors... Like when you selecting the area in Photoshop... or drawing new shape in other editors..
|
|
|
|
|
Hello
You can use DrawReversibleFrame and DrawReversibleLine methods of System.Windows.Forms.ControlPaint class for drawing selection regions or lines.
But, if you need SetROP2 function, you will need to interop it. [^]
Andrew
|
|
|
|
|
hi all,
I need to use 2 colors to root nodes and child nodes in a treeview.
How can I suceed this?
thanks in advance.
|
|
|
|
|
You can use the TreeNode object's ForeColor property. Checking if the node's Nodes collection is empty will tell you whether it is a leaf node.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
If you are using an image set the image index on OnAfterSelect event handler of the TreeView.
|
|
|
|
|
On the OnAfterSelect Event set the ImageIndex of the node to the image with colour of your wish.
|
|
|
|
|
Hi,
I've just had to expose a load of private members as public properties, and thought that regex should be able to do the trick. It did. Use the following:
search for
{.*}private {:c+} m_{:a+};
replace with
\1public \2 \3\n\1\{\n\1\tget \{ return m_\3; \}\n\1\tset \{ m_\3 = value; \}\n\1\}\n
Remember to enable regex.
Or save the following macro:
Sub PrivatesToProperties()<br />
DTE.ExecuteCommand("Edit.Replace")<br />
DTE.Find.ReplaceWith = "\1public \2 \3\n\1\{\n\1\tget \{ return m_\3; \}\n\1\tset \{ m_\3 = value; \}\n\1\}\n"<br />
DTE.Find.FindWhat = "{.*}private {:c+} m_{:a+};"<br />
DTE.Find.ReplaceWith = "\1public \2 \3\n\1\{\n\1\tget \{ return m_\3; \}\n\1\tset \{ m_\3 = value; \}\n\1\}\n"<br />
DTE.Find.Target = vsFindTarget.vsFindTargetCurrentDocumentSelection<br />
DTE.Find.MatchCase = False<br />
DTE.Find.MatchWholeWord = False<br />
DTE.Find.MatchInHiddenText = True<br />
DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxRegExpr<br />
DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResultsNone<br />
DTE.Find.Action = vsFindAction.vsFindActionReplaceAll<br />
DTE.Find.Execute()<br />
DTE.Windows.Item(Constants.vsWindowKindFindReplace).Close()<br />
End Sub
It will convert this:
private int m_blabla;
private string m_moreBla;
to this:
public int blabla
{
get { return m_blabla; }
set { m_blabla = value; }
}
public string moreBla
{
get { return m_moreBla; }
set { m_moreBla = value; }
}
but requires that you start with privates that are prefixed with "m_". And it doesn't uppercase the properties (blabla should be Blabla) - but the world isn't perfect
Just a tip - many of you probably already know it, but I didn't find it on CP so here it is.
/Jan
Do you know why it's important to make fast decisions? Because you give yourself more time to correct your mistakes, when you find out that you made the wrong one. Chris Meech on deciding whether to go to his daughters graduation or a Neil Young concert
|
|
|
|
|
Hi folks,
I recently reviewed some code from a collegue and I found he was using exceptions a great deal -- my gut feeling was that he was using them too much (his dictionary implementations throw exceptions if you pass a key for a non-existent entry, that sort of thing).
I set the IDE to break whenever an exception is thrown and I got bored after the 20th exception before the UI even displayed.
So my question is: What is the performance hit of exceptions, as opposed to returning a null or empty value?
Any pointers to articles would be especially useful as I will probably need hard data to win the argument.
Thanks
Herbie
Dr Herbie
Remember, half the people out there have below average IQs.
|
|
|
|
|
Dr Herbie wrote:
What is the performance hit of exceptions, as opposed to returning a null or empty value?
Exceptions are VERY expensive, especially the FIRST one (from what I have seen around 600ms). Exceptions are what they are, exceptional conditions (normally from external usage), not some internal bad coding habits. It all depends how your public object/interface will be used.
xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
|
|
|
|
|
It's recommended that you use as few exceptions as possbile. An exception should never occur in the normal execution of an application.
To use exceptions for the program flow is a lazy way of programming. It's slow, and there is a big risk that you accidentally catch any real errors that might occur, and ignore them.
---
b { font-weight: normal; }
|
|
|
|
|
Another way to look at this is to think in terms of contracts. With the data it's given can a routine fufil its contract, i.e., can it do what it says it can do? If it can then you shouldn't throw an exception. If it can't then it should fail, which means throwing an exception or signalling some other type of failure. Not being able to fulfil its contract is either due to a programmer error, or an environment error such as out of memeory. Either way it will be a rare occurrence.
I think in the situation you describe, your gut feeling is probably right.
Kevin
|
|
|
|
|
To add to what has already been said, it is my experience that any method that may throw an exception should have a way of determining whether that exception will be thrown.
To use your dictionary as an example... if the index accessor throws an exception when the key doesnt exist then that is fine.. so long as the Contains method always returns false for that key.
|
|
|
|
|
Here's a chapter from a design book on the subject Exceptions[^]. Also, Effective Java and More Effective C++ have good material. I have't seen Effective C#, but I suspect it has a similar take on them and they will all support your argument.
I'm not sure the performance angle is the best one to pursue though. I think it is better to point out that it is simply misuse of the feature. The purpose of exceptions is to deal with exceptional conditions.
Matt Gerrans
|
|
|
|
|
I am developing a plug-in to word that uses a webservice to take out information and insert it into bookmarks. For example I'm sending the bookmarkname "ProjectName" and the webservice retrieves the name of a particular project.
But I need to do the same with excel, does it exist a way to bookmark cells? Preferably together. I could use search and replace, but as the templates are not only used for this I want them to be able to use them normally too and it feels very clumsy to search and replace something in each cell.
I'm hoping that there exist some easier way so it will be more similar to the method I'm using with Word.
|
|
|
|
|
Hi, I am developing a web application, which consist of three pages, WebForm1.aspx, WebForm2.aspx, WebForm3.aspx, now I want to display WebForm3.aspx at the start of application. Where as, when I start, it shows WebForm1.aspx.
Tried this code, but it is not working
<authentication mode="Forms">
<forms loginurl="WebForm3.aspx">
plz help me,tell me is it a right way to gain the above purpose?
|
|
|
|