c# - Textbox looses forecolor on disabling it -


this question has answer here:

i dynamically create multiple textboxes showing information user. want set back- , forecolor of textboxes if statement true.

all works fine, untill disable textbox, forecolor "resets" standart color instead of showing desired one.

datatable dt = [some data] //col 0: id //col 1: text //col 2: date  (int = 0; < dt.rows.count; i++) {      datetime d = (datetime) dt.rows[i].itemarray[2];     textbox txt = new textbox();     txt.multiline = true;     txt.font = tb_aufloesung.font;     txt.text = dt.rows[i].itemarray[1].tostring() + "\n" + d.tostring(@"dd.mm.yyyy");     txt.size = new size((textrenderer.measuretext(dt.rows[i].itemarray[1].tostring(), txt.font).width) + 10, 34);     txt.location = new point(43, 3 + split.panel2.controls.count / 2 * 40);      if(d <= datetime.now) {         txt.backcolor = color.red;         txt.forecolor = color.white;     }          //txt.enabled = false;      split.panel2.controls.add(txt); } 

this how textboxes when use code above :

  1. comment line -> //txt.enabled = false;
  2. uncomment line -> txt.enabled = false;

enter image description here

i have no idea why in second case, forecolor of red textbox not white should be. idea?

this how textboxes work - they're meant input, not display. why not use label?


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -