Autor Beitrag
Necaremus
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 203
Erhaltene Danke: 18

Win > XP, Vista, 7; Android 2.1
C# > VS '08,'10; Delphi7
BeitragVerfasst: Do 16.09.10 14:27 
Hi,

wie krieg ich es hin, dass ich aus einem seperatem thread die form bearbeiten kann?
wollte ein paar buttons enablen/disablen... aber bekomm halt immer ne exception :D

wäre für nen kleines snippet sehr dankbar ^^
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4796
Erhaltene Danke: 1059

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Do 16.09.10 14:31 
Stichwort: Control.Invoke bzw. Control.BeginInvoke, s.a. www.mycsharp.de/wbb2...d.php?threadid=33113
Necaremus Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 203
Erhaltene Danke: 18

Win > XP, Vista, 7; Android 2.1
C# > VS '08,'10; Delphi7
BeitragVerfasst: Mi 29.09.10 09:04 
mal doofe frage:

warum wirft der code ne out-of-range exception (101 ist größer als MaxValue)
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
delegate void IntParameterDelegate(int value);
        public void SetProgBarValue(int value)
        {
            if (progressBar.InvokeRequired)
            {
                if (value > 100// überflüssig, aber ich habs einfach nochmal eingebaut um zu zeigen, was ich meine
                    value = 100;
                progressBar.Invoke(new IntParameterDelegate(SetProgBarValue), new object[] { value });
                return;
            }
            progressBar.Value++;
            progressBar.Value--;
            progressBar.Value = value;
        }

        private void SimpleProgressBarChanger()
        {
            int value = 0;
            while (doProgBarChange)
            {
                if (value == 100)
                    value = 0;
                SetProgBarValue(++value);
                Thread.Sleep(350);                
            }
        }
danielf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1012
Erhaltene Danke: 24

Windows XP
C#, Visual Studio
BeitragVerfasst: Mi 29.09.10 10:56 
Hallo,

deine progressbar hat eine Eigenschaft Namens MaxValue. Diese legt fest was der höchste bzw. (MinValue) der niedrigste Wert für den Progressbar ist. Standard ist 0 und 100, was wohl daran liegt, dass man praktisch 0-100% so Abbilden kannst. Du solltest also deinen Fortschritt auf 100 skalieren oder die Progressbar Wertebereich anpassen.

Gruß
Ralf Jansen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 4708
Erhaltene Danke: 991


VS2010 Pro, VS2012 Pro, VS2013 Pro, VS2015 Pro, Delphi 7 Pro
BeitragVerfasst: Mi 29.09.10 11:12 
Zitat:
warum wirft der code ne out-of-range exception (101 ist größer als MaxValue)


Wo im Code?

ausblenden C#-Quelltext
1:
progressBar.Value++;					



hier? Dann sollte dich das nicht wundern.
Necaremus Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 203
Erhaltene Danke: 18

Win > XP, Vista, 7; Android 2.1
C# > VS '08,'10; Delphi7
BeitragVerfasst: Mi 29.09.10 11:15 
ja, der pbar hack war dran schuld, müsste mit -- statt ++ anfangen^^
dass ich das nicht selber gesehen habe...
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4796
Erhaltene Danke: 1059

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Mi 29.09.10 11:54 
Zitat:

progressBar.Value++;
progressBar.Value--;
progressBar.Value = value;

Was sollen die oberen zwei Zeilen denn eigentlich bewirken?