|
Hello,
I think the error you made, is choosing this FilterTextBox!
There are much better articles here on CP.
After a quick search I found code like:
this.SelectionStart = p-1;
Without any validation before.
So really I think the error comes from the Control youre usercontrols inherit from.
P.S.: You should use double.TryParse instead of Convert.ToDouble.
All the best,
Martin
|
|
|
|
|
Hmm... yeah, there are a few... Which do you recommend? I don't wanna choose a bad one again... Thanks!
Windows Calculator told me I will die at 28.
|
|
|
|
|
|
OK, I'll try 'em! Thanks!
Windows Calculator told me I will die at 28.
|
|
|
|
|
Can I check if a given handler is assigned to an event.
I'm having problems with events I want to fire in most cases, but not under a few specific instances. I'm currently using InstallFooHandlers() and RemoveFooHandlers() to control the firing, but the system breaks down in one case where methods Bar() and Baz() both need the handlers disabled, but Bar() calls Baz() internally, because at their conclusion's both methods install the handlers resulting in two copies being attached to each event and the next pass through not removing them. Putting a pair of install/remove calls around Bar() 's call of Baz() would work but I'd prefer something less kludgey if possible.
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
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
|
|
|
|