i've created custom text editor c# . now, add syntax highlighting feature coloring last letter/number inputted, in way color used drawn on random basis . how can so, though? tried bunch of alternative ways none worked . recommendations! (note: i've been coding 2 months. sorry mistakes ! )
latest example :
private void usertb_keypress(object sender, keypresseventargs e) { random rnd = new random(); color randomcolor = color.fromargb(rnd.next(255), rnd.next(255), rnd.next(255)); usertb.selectioncolor = randomcolor; }
try putting "static" in front of variable declaration.
static random rnd = new random();
your code getting fired off button event, , random variable getting created anew each time button clicked, , begins random sequence @ same starting point each time.
===== grayish? hmm. try perhaps...
static random rnd = new random(); static int r1; static int r2; static int r3; r1 = rnd.next(255); r2 = rnd.next(255); r3 = rnd.next(255); color randomcolor = color.fromargb(r1, r2, r3);
and take @ r1, r2, , r3 values in debugger.
Comments
Post a Comment