muratboy31 Posted June 1, 2015 Share Posted June 1, 2015 (edited) Merhaba arkadaşlar, devexpress gridControl1 içinde bir progress bar göstermeye çalışıyorum fakat bir türlü beceremedim; yapmak istediğim 4. kolondaki hücrelerdeki değeri maximum olarak belirlemesi ve 5. kolondaki hücre değerlerine göre progressbar değerlerini vermesi... 4. Kolon 5. Kolon Maximum Gerçekleşen 15000 12300 22000 20900 7800 6500 RepositoryItemProgressBar ritem = new RepositoryItemProgressBar(); for (int i = 0; i < aColumnView.RowCount; i++) ritem.Maximum = Convert.ToInt32((gridView1.GetFocusedRow() as DataRowView).Row[i].ToString()); ritem.ShowTitle = true; aColumnView.Columns[5].ColumnEdit = ritem; Edited June 1, 2015 by muratboy31 Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted June 1, 2015 Editor Share Posted June 1, 2015 Veritabanındaki iki kolonum. Grid üzerine aktarılmış hali. using (MySqlConnection con = new MySqlConnection("Server=localhost;Database=database;Uid=root;Pwd=;")) { con.Open(); if (con.State == ConnectionState.Open) { using (MySqlDataAdapter adapter = new MySqlDataAdapter("select * from stok LIMIT 3", con)) { using (DataTable dt = new DataTable()) { adapter.Fill(dt); gridControl1.DataSource = dt; using (RepositoryItemProgressBar rProgress = new RepositoryItemProgressBar()) { gridView1.Columns[8].ColumnEdit = rProgress; for (int i = 0; i < 2; i++) { int nMax = Convert.ToInt32(gridView1.GetRowCellValue(i, gridView1.Columns[7])); int nVal = Convert.ToInt32(gridView1.GetRowCellValue(i, gridView1.Columns[8])); rProgress.Maximum = nMax; rProgress.Step = nVal; gridControl1.RepositoryItems.Add(rProgress); } } con.Close(); } } } } Kullandıgım kodlarda bu şekilde. Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted June 2, 2015 Author Share Posted June 2, 2015 pairs teşekkürler ama şöyle bir problem var, aşağıdaki kodu kullandığımda veriyi tam olarak progress doğru değeri göstermiyor ! RepositoryItemProgressBar rProgress = new RepositoryItemProgressBar(); gridView1.Columns[6].ColumnEdit = rProgress; for (int i = 0; i < 2; i++) { int nMax = Convert.ToInt32(gridView1.GetRowCellValue(i, gridView1.Columns[6])); int nVal = Convert.ToInt32(gridView1.GetRowCellValue(i, gridView1.Columns[5])); rProgress.Maximum = nMax; rProgress.Step = nVal; rProgress.ShowTitle = true; gridControl1.RepositoryItems.Add(rProgress); } veri tabanındaki değer ; progress değeri (22000 olan yanlış gösteriyor) benim istediğim onaylı olanı max olarak alıp her satırdaki harcananın onun yüzde kaçı olduğunu göstermesi.. Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted June 2, 2015 Author Share Posted June 2, 2015 Ne yaptıysam doğru değeri almayı beceremedim !!! RepositoryItemProgressBar rProgress = new RepositoryItemProgressBar(); gridView1.Columns["Gerceklesen"].ColumnEdit = rProgress; for (int i = 0; i < gridView1.RowCount; i++) { int nMax = Convert.ToInt32(gridView1.GetRowCellValue(i, gridView1.Columns["Onaylanan"])); int nVal = Convert.ToInt32(gridView1.GetRowCellValue(i, gridView1.Columns["Gerceklesen"])); rProgress.Maximum = nMax; rProgress.Step = nVal; rProgress.ShowTitle = true; gridControl1.RepositoryItems.Add(rProgress); } veri tabanındaki değer ; yanlış değerler veriyor Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted June 2, 2015 Editor Share Posted June 2, 2015 100 ü geçtikten sonra maximum değeri % olarak gösteriyor değerleri. Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted June 2, 2015 Author Share Posted June 2, 2015 (edited) Ama 6500 ü %83 olarak gösteriyor, ben tam anlayamadım çalışma mantığını ! aslında yapmak istediğim; onaylanan paranın yüzde kaçının gerçekleştiği(yane harcandığı) Edited June 2, 2015 by muratboy31 Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted June 2, 2015 Editor Share Posted June 2, 2015 Kodlarını şu şekilde düzenlersen durum düzelecektir. RepositoryItemProgressBar rProgress = new RepositoryItemProgressBar(); gridView1.Columns[6].ColumnEdit = rProgress; for (int i = 0; i < 2; i++) { int nMax = Convert.ToInt32(gridView1.GetRowCellValue(i, gridView1.Columns[6])); int nVal = Convert.ToInt32(gridView1.GetRowCellValue(i, gridView1.Columns[5])); rProgress.Maximum = nMax; rProgress.PercentView = false; rProgress.ShowTitle = true; gridControl1.RepositoryItems.Add(rProgress); } Oradaki görünen değerler yani sendeki aslında percent dediğimiz % lik kısmı. Biz percent View i kapatırsak normal değeri gösterecektir. Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted June 2, 2015 Author Share Posted June 2, 2015 ben böyle bir formül denedim messagebox kullnarak baktım sonuç doğru çıkıyor ama float yaptığım için sorun çıkıyor grid e ekleyemiyorum...; sorun yüzde hesaplama ile alakalı sanıyorum... int nMax = Convert.ToInt32(gridView1.GetRowCellValue(i, gridView1.Columns["Onaylanan"])); int nVal = Convert.ToInt32(gridView1.GetRowCellValue(i, gridView1.Columns["Gerceklesen"])); float hesap = (nMax - nVal); float hesap2 = (hesap / nMax) * 100; MessageBox.Show(Convert.ToString(hesap2)); Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted June 2, 2015 Editor Share Posted June 2, 2015 Yukarıdaki verdiğim kodlar ile ikinci kolondaki değereler göre düzgün çalışıyor zaten. Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted June 2, 2015 Author Share Posted June 2, 2015 hayır verdiğin kodla 2000 olan progressbar 1400 de full görünüyor, normalde %70 gibi biyerde olması lazım... peki hesap3 değişkenini nasıl yüzde olarak ekleyebilirim, test ettim mesaggebox ta doğru göstriyor; RepositoryItemProgressBar rProgress = new RepositoryItemProgressBar(); gridView1.Columns["Gerceklesen"].ColumnEdit = rProgress; for (int i = 0; i < gridView1.RowCount; i++) { int nMax = Convert.ToInt32(gridView1.GetRowCellValue(i, gridView1.Columns["Onaylanan"])); int nVal = Convert.ToInt32(gridView1.GetRowCellValue(i, gridView1.Columns["Gerceklesen"])); float hesap = (nMax - nVal); float hesap2 = (hesap / nMax) * 100; float hesap3 = 100 - hesap2; rProgress.Maximum = nMax; rProgress.PercentView = false; rProgress.ShowTitle = true; gridControl1.RepositoryItems.Add(rProgress); MessageBox.Show(Convert.ToString(hesap3)); } Quote Link to comment Share on other sites More sharing options...
KintaRo Posted June 2, 2015 Share Posted June 2, 2015 projeyi çok incelemedim ama sanırım şurada bir değerin yüzde x'ini bulmaya çalışıyorsunuz. yüzde hesaplama şu şekilde yapılabilir: ana sayı: 75 bulmak istediğimiz değer: %15 (75 / 100) x 15 = 11,25 yani float hesap2 = (hesap / 100) * nMax Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted June 2, 2015 Author Share Posted June 2, 2015 yapmak istediğim şu; mesela elimde 2000 TL var ve ben bunun 1500TL sini harcadım, paramın yüzde kaçını harcadığımı bulmak istiyorum ve progressbarda onu göstrmek istiyorum yüzde olarak... Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted June 2, 2015 Editor Share Posted June 2, 2015 o zaman percentview i true yapın veritabanındada elimdeki para | harcanan para dyie iki kolonunuz oldugunu varsayalım siz progressin max ını 2000 olan kolondan alırsanız percent açık oldugu için size 1500 ün 2000e oranla %desini gösterecektir Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted June 2, 2015 Author Share Posted June 2, 2015 yine olmadı :( kafayı yicem RepositoryItemProgressBar rProgress = new RepositoryItemProgressBar(); gridView1.Columns["Gerceklesen"].ColumnEdit = rProgress; for (int i = 0; i < gridView1.RowCount; i++) { int nMax = Convert.ToInt32(gridView1.GetRowCellValue(i, gridView1.Columns["Onaylanan"])); rProgress.Maximum = nMax; rProgress.PercentView = true; rProgress.ShowTitle = true; gridControl1.RepositoryItems.Add(rProgress); } veri tabanı değerleri bu; ancak 1400 olduğu halde %100 gösteriyor... Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted June 3, 2015 Editor Share Posted June 3, 2015 (edited) 3.bir kolona şu değeri yazdıracaksınız. (kolon2 / kolon1) * 100 bu formülde 3. kolona değeri yazıp percentview = false derseniz size elinizdeki paranın ne kadarını harcadıgınızı gösterir. veya bunu veritabanından çekerkende yapabilirsiniz. Select OLAN,HARCANAN,((HARCANAN / OLAN) * 100) as 'HARCAMA ORANI' from tabloismi bu şekildede yine siz 3.kolonu şayet progress kolon yaparsanız direk gösterecektir. Ama unutmayın percentview kapalı olacak. Edited June 3, 2015 by pairs Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted June 3, 2015 Author Share Posted June 3, 2015 (edited) teşekkürler pairs sıfırlardan nasıl kurtulabilirim... Edited June 3, 2015 by muratboy31 Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted June 3, 2015 Editor Share Posted June 3, 2015 https://documentation.devexpress.com/#windowsforms/CustomDocument3048 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.