|
Can you hack numericupdown's to change the arrow button's width? or do you have to make one from scratch if you want bigger buttons?
|
|
|
|
|
You won't be able to hack the arrow button's width. The method PositionControls() in the UpDownBase class determines it's width. This class is private and would override any possible hacks.
Your best option would probably be to build a UserControl using a TextBox and two Buttons.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Hi to all, I work on an application that takes measurements from a piece of hardware, and
then manipulates it.
my problem is that while collecting the measurement my program gets stuck, meaning if I do something else on my PC at the same time, when I return to my form it is blank.
I understand it's a matter of threading.
the problem is I can't call my callback function passed to the new thread with the ProgressBar parameter.
my Form creates a ProgressBar that my collecting function is supposed to operate, but it can't.
I get the error,
Cross-thread operation not valid: Control 'progressBarSampling' accessed from a thread other than the thread it was created on.
What I want to achieve is to be able to pass the Form's progressbar as parameter to my function
so it can use it.
Any help will be most appreciated.
regards.
|
|
|
|
|
You might want to take a look at the BackgroundWorker class. This will help you immensely.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
What do you mean by that?
that I should look for global information about the class?
|
|
|
|
|
I mean that if you search through that mystic portal called google on BackgroundWorker and take a look at some of the samples and articles, you'll see how this works and how it might help to solve your issue.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
The reason I asked you is because I thought maybe you are trying to direct me to problem specific
solution and not such a global shot in the air.
as far as I know, and I don't know much on that subject, a background worker only means it a thread that works in the back, how is that supposed to solve the problem of passing a form component to a
thread other then the one that created it, I don't know, but I am reading some material about that.
if you could direct me to some more problem specific information I will be most grateful.
|
|
|
|
|
Read up on the BackgroundWorker[^] class and it will be come clear. It gives you the option of reporting progress to your UI thread.
|
|
|
|
|
thanks I'll catchup on that
|
|
|
|
|
O.K
I read about background Worker but now I have another question,
my main problem is, that I run ,on my BGWorker, a function from a different class.
I want that function to report progress so I can update the progressBar that belongs to my form.
how do I make it possible for the function to update my outside control, or even call
the reportProgress??
Waiting for your help...
thanks in advanced.
private void OffsetAButton_Click(object sender, EventArgs e)
{
frmPicoBackgroundWorker.DoWork += new DoWorkEventHandler(frmPicoBackgroundWorker_DoWork);
frmPicoBackgroundWorker.ProgressChanged +=new ProgressChangedEventHandler(frmPicoBackgroundWorker_ProgressChanged);
frmPicoBackgroundWorker.RunWorkerAsync(updateProgress);
}
private void frmPicoBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
PICO.start_ChannelA_Offsetting(ref updateProgress);
frmPicoBackgroundWorker.ReportProgress(updateProgress);
}
private void frmPicoBackgroundWorker_ProgressChanged(object Sender, ProgressChangedEventArgs e)
{
progressBarSampling.Step = updateProgress;
progressBarSampling.PerformStep();
}
these are just samples of the problematic code.
hope it helps you understand what I don't understand
|
|
|
|
|
It would help if your worker method took a parameter which you could pass in the background worker instance. Your worker code then, every once in a while, calls the ReportProgress method on the BackgroundWorker object to fire off the ProgressChanged event.
|
|
|
|
|
Right - here we go, and I'll try not to digress. You have a form that you don't want to be put on hold while you have something else going on, and you want to display a progress bar. Rather than trying to pass the form component to another thread, you should delegate the measurement code to a background thread and handle the update on the main UI. Using the BackgroundWorker class makes the whole issue really easy.
This[^] article gives a sample and was found by googling on BackgroundWorker and progressbar. There are many more examples there.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks, now I now what to look for
|
|
|
|
|
Hi
I am (as can be seen from my profile) an aspiring C# programmer/developer. I am living in the UK and am seeking to get in contact with other C# students or experienced programmers. I am close to London and would like to setup some kind of informal study groups with other C# students in the same area.
I am sure there must be people out there with similar needs.
I am currently using this forum to read about coding queries and the like but I would still like some live demonstrations or discussions.
Contact me here if you are interested.
Thanks
Francois Benadie
Francois Benadie
|
|
|
|
|
You should really post this in this[^] forum.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I would like to be able to invoke a button_clicked event via the function keys (F1, F2, etc.). Any links to articles or helpful code snippets would be greatly appreciated thanks everyone.
|
|
|
|
|
Handle the KeyDown event of the form which contains the button and test for the key that was pressed. If it is the function key you want to process, call the event handler of the button
|
|
|
|
|
I added the KeyDown event to the form, and added a breakpoint in the definition, and when I debug it isn't running when I press a key. *looks confused*
|
|
|
|
|
Examine the e.Keydata property in the event handler to see whether it is equal to functional key or not
|
|
|
|
|
I'm examining the keydata.. but the event isn't being triggered when I press a key. So, the code to examine the key is never running. I have a keydown method set up to run on the keydown event, but for some reason it isnt being executed when I press a key..
|
|
|
|
|
Set KeyPreview property of your form to true
|
|
|
|
|
Alternatively (if applying to a form with menus), add those commands to some menu in the
main menu, and give it the function keys as a shortcut. No coding required!
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi all sorry for asking, but how do i calculate time"hh:mm:ss" / int(pages) *100.
for example 00:00:10 / 10 *100
Gonna count the time of 100 pages...
big reggards!!
Thanks
|
|
|
|
|
andredani wrote: Hi all sorry for asking, but how do i calculate time"hh:mm:ss" / int(pages) *100.
for example 00:00:10 / 10 *100
Gonna count the time of 100 pages...
Have you taken a look at the DateTime and TimeSpan classes? I suspect that would provide you with the answer.
Good Luck!
It isn't enough to do well in life.
One must do good when and where one can.
Otherwise, what's the point?
|
|
|
|
|
I'd go with what Matthew said.
But why are you multiplying the pages by 100?
Using pseudo-code, you've written:
TimeSpent / NrOfPages * 100
Best regards!
-Larantz-
|
|
|
|