|
Hello,
In this case you have to work with a timer. (System.Windows.Forms.Timer for example)
You set the Enable Property true at Mouse Down.
In the tick event code you than add the mousedown code.
At mouse up you have to set Enable to false. (Also at MouseLeave to be sure)
Hope that helps,
All the best
Martin
|
|
|
|
|
Thanks for the quick reply!
Sounds good I will use a Timer then..
Thanks
-Kevin
|
|
|
|
|
I have not done this, but I expect you can use a regular Button, give it no text,
but add a picturebox to its Controls property, hence combining the best of both.
Luc Pattyn
|
|
|
|
|
I'm writing a form based app using the tab control. I want to make the app as modular as possible so it will be easy to modify and extend.
My intention is to subclass TabPage and design each tab separately so it can be "plugged in" to the main app (at compile time, not run time). Ideally, my subclassed TabPage would be usable in the form designer to lay out the controls for that tab.
In practice, however, I'm finding that form designer will not display my subclassed TabPage in design view, it will only show me the controls present on the page as icon view. My question is this: Is there any way to make my subclassed TabPage show up in form designer the way I want?
Thanks,
Trent R
|
|
|
|
|
One solution would be to use a UserControl / Panel which would allow you to lay out the controls as you want.
You could then either load this custom control onto a tab page, or you could simply change the inherited class from UserControl to TabPage, hopefully the layout logic that was generated by the designer will remain there (it might disappear though if you try and re-load it into the designer).
The safest would probably be to use a UserControl as the "subclassed" TabPage and then simply drop this onto an existing tab page.
I have no idea what I just said. But my intentions were sincere.
Poore Design
|
|
|
|
|
|
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
|
|
|
|