|
I think if you override the handler in a sub class you can use the new delegate to check for listeners.
public partial class myButton : Button
{
public myButton()
{
InitializeComponent();
}
public event ClickHandler Click1;
public delegate void ClickHandler(EventArgs e);
public myButton(IContainer container)
{
container.Add(this);
InitializeComponent();
}
protected override void OnClick(EventArgs e)
{
if (null != Click1)
Click1(e);
base.OnClick(e);
}
public bool HasListener
{
get { return (null != Click1); }
}
}
|
|
|
|
|
I was wondering if there was something simpler to do
When you create a dataset from reading in SQL database for string values you obtain a column with th full lenght of the SQL column, thus when you bind to a Textbox you do have spaces at the right end of the data.
I can use RTRIM(data) in the SQL statetment of course but is there an easier way to trim I don't know about ?
|
|
|
|
|
Use nvarchar, then there's no padding.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hello All:
In C#.NET 2005, I have created a Button on the Form. When the user click on the Button, it will execute an external application. Could someone pleasae help me how would I go about doing that. Thanks in advance.
|
|
|
|
|
Use Process.Start.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Look at the System.Diagnostics.Process object. It should have everything you need.
Brent
|
|
|
|
|
Thank you for your reply guys..
I used the proc = System.Diagnostics.Process.Start("C:\\xxxx.exe"); That part works fine.
One more question though - I need to add parameter with that external application. How can I do that??
Thanks again for your help.
|
|
|
|
|
|
there's an overload:
System.Diagnostics.Process.Start("C:\\xxxx.exe", "parameters");
life is study!!!
|
|
|
|
|
|
I am comparing disk files to see if they are the same. (I don't care about the details, I just want a yes/no result.) Currently, I am loading a pair of byte arrays with System.IO.FileStream.Read() and then comparing them using a for loop. This works, but I was wondering if there is a more efficient way to handle it. The current implementation seems to be pretty slow. (I haven't been able to find the .NET equivalent of "memcmp".)
Also, how much of a factor is the array size? Is it better to read 1KB at a time from a file or 1MB?
Thanks!
|
|
|
|
|
I'd read it in small chunks, unless you know the files will never be huge. Otherwise, they will sit in memory.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
You can use a block of unsafe code, then you can use pointers, and compare the data int by int instead of byte by byte. Then you get more or less what memcmp would do. You have to pin the buffers in memory first, though, so that the garbage collector can't move them.
The buffer size doesn't matter much, unless it's very large or very small. If you create objects that are larger than 85 kB, they will be allocated from the large objects heap. The large objects heap can only grow, it never gives any memory back to the system even if the memory is not used, so you should avoid greating large objects if you can.
---
Year happy = new Year(2007);
|
|
|
|
|
Before loading an entire file, or big chuncks of it, I would suggest:
- to compare file length
- if considered relevant for equality, compare file dates
- then simply compare a few bytes at specific locations (e.g. at offsets 0, 1024, 10240,
length-10240, length-1024, length-1).
- only then perform a systematic comparison.
Of course the sequence should be terminated as soon as a difference has been found.
Luc Pattyn
|
|
|
|
|
I need this registry values to insert.
"ValueName"=hex:fd,d5,72,d6,8b,6a,8a,6f,d5,33,95,fd"
But i only know how to insert a string values.
Help.
Vasildb
|
|
|
|
|
Hello Vasildb,
I think you have to convert your HEX string too int32.
If you have .Net >1.1 you can use Int32.TryParse.
public Int32 HexToInt32(string hexString, Int32 default)
{
Int32 actvalue;
if(Int32.TryParse(hexString, System.Globalization.NumberStyles.HexNumber, CultureInfo.CurrentCulture, out actvalue))
{
return actvalue;
}
else
{
return default;
}
}
Int32 actvalue = HexToInt32("fd", 0);
if(actvalue!=null)
{
YourRegKey.SetValue("Name", actvalue);
}
Have not testet it, so I hope it works for you.
All the best,
Martin
|
|
|
|
|
In .NET 1.x you could only read/write strings (REG_SZ entries) in the registry with the managed
classes (RegistryKey). For other entry types (such as REG_DWORD) you had to use PInvoke.
Since .NET 2.0 there is also support for the other entry types, through the new
RegistryValueKind enum, and new methods in RegistryKey class such as RegistryKey.GetValueKind()
Luc Pattyn
|
|
|
|
|
Hello,
I've been retrieving the hidden text from a link (RichTextBox link) using the following:
private int GetFirstHiddenCharacter(int position)
{
this.Select(position, 1);
while (this.SelectionType != RichTextBoxSelectionTypes.Empty)
{
position++;
this.Select(position, 1);
}
return position;
}
then using a substring function to get the rest of the hidden text.
Anyone know of a more elegant way to do this? i.e. without selecting each character.
Thanks.
Abisodun
|
|
|
|
|
Hello,
When I/O performance is slow (because of large file copy or OS deployment via network), my .NET application performs much slower than normal Windows apps like Explorer. It seems that my .NET application needs frequent disk access and does not use any caching. I found this out while running a low-memory virtual machine (like 256MB) and doing a large file copy and then trying to minimize and maximize my .NET application.
How can I improve the performance? Does someone know tips to improve the performance?
Thanks.
|
|
|
|
|
I would start by looking at the CLR assemblage of your application. You should look for boxing/unboxing calls as these are an easy thing to fix performance wise. Let me look around, I got a slide presentation from Tom Fuller on this very issue. A good tool for looking at the clr is Reflector.
Hope this helps.
_____________________________________________________________________
Our developers never release
code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
Visit Me at GISDevCafe
|
|
|
|
|
If your app needs lots of disk accesses it is likely to be IO bound, not CPU bound.
And yet you see it reacting slowly (or not at all?) to minimize/maximize commands.
Maybe I am misunderstanding what you describe, it sounds to me you are doing disk
operations from within the UI thread and complaining about UI responsiveness.
If so, start using a couple more threads...
Luc Pattyn
|
|
|
|
|
No, My application is not doing any disc activity. But windows is doing that.
I think maybe my problem comes from the background image that i have in my application.
Is there a way to cache it, speed the refresh up or just don't refresh it?
|
|
|
|
|
please be much more specific as to what is going on on your system, and what you
observe. Just a few questions, but incomplete since I dont know your stuff:
large file copy: how large ? how long does it take normally ?
is the large file copy invoked by your app, or is it an independent system activity ?
if by your app, is it invoked by the UI thread ?
between which devices is the copy ?
if not doing large file copy how fast/slow is a form maximize/restore/minimize ?
and with large file copy, how fast then.
What is the complexity of the form, what is special to it, how large is your background
image, is it the form's background, your desktop or what ? where is it stored ?
(should not be a problem if reasonable size = less than 10MB, on a normal local hard disk
that is not otherwise overloaded, and without memory shortage).
What is your memory situation: how much RAM, what is your app's working set, does
it need large objects (over 30 MB each) ?
Are there other anomalies: slow resizing, slow painting, jerky behavior, whatever...
How is CPU load (watch task manager/performance) when things go normal, and when
things go slow.
Luc Pattyn
|
|
|
|
|
Hi people
i have 1 question ! How to edit pascal document from c# !? I have compiler only to edit and compile!!??
Thx
nemanja
|
|
|
|
|
You just want a text editor ? Do you want syntax highlighting and so on ? If so, you need to write a control to do it.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|