-2
Çalışma zamanında WPF'de Artalan Rengi Düğmesi (Adlar: b0, b1, b2, b3, b4, b5, b6, b7, b8, b9) ayarlamaya çalışıyorum.Çalışma zamanında WPF'deki Düğmenin Arka Plan Rengi Ayarı
Renk Adı, şu anda Kırmızı olan Veritabanından geliyor. Ama System.NullReferenceExceptionn beni veriyor:
private void ButtonBgColor()
{
string qryBgColor = "select Name from lookup where code in (select VALUE from qSettings where name='BUTTON_BG_COLOR') and type='BgColor'";
try
{
sqlConnection.Open();
sqlCommand = new SqlCommand(qryBgColor, sqlConnection);
sqlDataReader = sqlCommand.ExecuteReader();
if (sqlDataReader.Read())
{
string BUTTON_BG_COLOR = sqlDataReader["Name"].ToString();
Button[] b = new Button[9];
for (int i = 0; i < b.Length; i++)
{
var textBlock08 = (TextBlock)b[i].Template.FindName("myTextBlock", b[i]);
textBlock08.Background = (System.Windows.Media.SolidColorBrush)new System.Windows.Media.BrushConverter().ConvertFromString(BUTTON_BG_COLOR);
}
}
}
catch (Exception exp)
{
MessageBox.Show(exp.ToString(), "Button Background Color Exception");
}
Herkes bana bu sorunu çözmek için yardımcı olabilir
nesne başvurusu bir nesnenin örneğine ayarlanmadı? Sen b şey atanmamış olan peşin
Loop'ta NULL nasıl olabilir? –
Diziniz boş değil, dizinin içindeki her öğe boş. – Jace
b0, –