|
Those look reasonable, but check for System.DBNull.Value
Here's my current code for ExecuteScalar:
public virtual T
ExecuteScalar<T>
(
T IfNull
)
{
lock ( this.command )
{
try
{
this.OpenCount++ ;
object result = this.command.ExecuteScalar() ;
if ( ( result == null ) || ( result == System.DBNull.Value ) )
{
result = IfNull ;
}
else if ( typeof(T) != result.GetType() )
{
result = System.Convert.ChangeType
(
result
,
typeof(T)
) ;
}
this.RaiseEvent ( this.OnSuccess , 1 , null ) ;
return ( (T) result ) ;
}
catch ( System.Exception err )
{
throw ( this.WrapException
(
"ExecuteScalar"
,
this.command
,
err
) ) ;
}
finally
{
this.OpenCount-- ;
}
}
}
|
|
|
|
|
Hi all,
In my windows application by using the openfiledialog box i am selecting a program or .exe application.
After selecting i want to get the signature of the application which i have selected.
Is it possible in c#.If yes how can i ?
Thanks in advance.
|
|
|
|
|
What do you mean by signature? Are you talking about the digital signature, or do you mean something else?
|
|
|
|
|
|
This[^] article might help you.
|
|
|
|
|
No idea why this answer was downvoted!
Have my 5+
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
Thanks. Lately, I see many univotes to my answers and posts. I raised my concern at the Site Bugs & Suggestions forum, it was rejected outright.
|
|
|
|
|
Please clarify on what do you mean by signature of the application and what do you want to do with this signature.....
I quit being afraid when my first venture failed and the sky didn't fall down.
|
|
|
|
|
hello guys... Lets say I have a text box on a form. I was trying to get the coordinates of a specific letter i-e "." (dot) when I type it, in text box on the form. For simple drawing this can be done but for typing, I am finding it hard. Any pointers will be appreciated...thnx
|
|
|
|
|
I think some lateral thinking is required for this.
First, find the coordinates of the text starting position. That will be the text box's Location, plus a bit for borders and padding, which you can either hard code as an assumption or infer from the difference between Size and ClientSize.
Then measure the text, using Graphics.MeasureCharacterRanges[^]* (you can create a graphics object from the text box itself if you don't have one). Use the Font object from the text box. Note that you aren't measuring the text within the textbox, but you're measuring the same string with the same font in the same graphics context, so it should be the right answer!
Finally simply add the measured text size to the inferred start of the client area.
(*: Not MeasureString. See this short article[^].)
|
|
|
|
|
nicely explained.......
I quit being afraid when my first venture failed and the sky didn't fall down.
|
|
|
|
|
A question: what are you going to do when you know the position where the user typed a 'dot (I assume by 'dot you mean the OEMPeriod character in Windows).
The reason I ask is: if you do not require pixel-perfect typographic accuracy, there is a way (if 'ugly') that does not use a 'Graphics object, or 'MeasureString(...).
If you do require high-accuracy, then I'd definitely go with Bob Janova's excellent answer (his answer just got my #5).
And, if the scenario is one where you know the Font being used in the TextBox is mono-spaced (i.e., Courier or the like), then there is a much simpler way (not so 'ugly,' either).
You want to see code for 'ugly,' just ask here
best, Bill
"In the River of Delights, Panic has not failed me." Jorge Luis Borges
|
|
|
|
|
iam working on c# 4 solution
i have datagridview
i add datagridviewimagecolumn to datagrid
i give it fixed image from embded resource from design not from code
in design & in the run the default (x image) appear & my image doesn't appear
so what is the probelm
md_refay
|
|
|
|
|
Hellou,
Want to make a simple dictionary, translator which uses Google API to translate from English to Spanish, and inversely. All that is done, but now I want to make dictionary gets data from Clipboard if it's a text, and is no longer of 4,5 words.
I have found this class and operations with that class:
IDataObject iData = Clipboard.GetDataObject();
if(iData.GetDataPresent(DataFormats.Text))
{
textBox1.Text = (String)iData.GetData(DataFormats.Text);
}
I've tried to put this in Timer tick event but have problem cause interval doesn't allow me to manually add other text. I could put higher interval, but that doesn't give on performance and again is possible to change user input when event is raised.
It's very important to know that I want to retrieve data when somewhere from outside of program I copy some text (for exl. Word, Calculator, etc.).
Any help? Thanks
|
|
|
|
|
Not without using some P/Invoke to get information about when the clipboard changes. The Clipboard class doesn't expose any events.
You could try retaining a cache of what was in there last time you looked, and only setting the text if the clipboard contents have changed.
|
|
|
|
|
Sorry, don't undestand. I'm beginner.
|
|
|
|
|
This[^] article contains an implementation of Clipboard monitoring using P/Invoke.
|
|
|
|
|
See my Talking Clipboard[^] article for help on monitoring the clipboard. See my Google Translator[^] article for help on invoking Google's translation service from your app.
/ravi
|
|
|
|
|
I haven't got it.
Code which I posted here is working.
But, I need to make some process in VS which would watch nonstop over the clipboard and paste values if text is up to 256characters for example.
What invoke means exactly?
How to use that exactly?
when you have time answer, it's not important very much, just for learning
kind regards
|
|
|
|
|
By "invoke", I meant "call" or "use".
/ravi
|
|
|
|
|
i want to add image to (data gridview button column )but i don't know how
md_refay
|
|
|
|
|
|
i mean add image as background to button
md_refay
|
|
|
|
|
OK, try changing the keywords in the Google link I gave you and see what it comes up with.
|
|
|
|
|
what is the different between .net frame work 4 &.net frame work 4 client profile
i found these 2 option in the target frame work so what is the different & when to use each one
md_refay
|
|
|
|