Lokasi Iklan

Info lebih lanjut kirim email ke evocrus@gmail.com

Lokasi Iklan

Info lebih lanjut kirim email ke evocrus@gmail.com

Lokasi Iklan

Info lebih lanjut kirim email ke evocrus@gmail.com

Lokasi Iklan

Info lebih lanjut kirim email ke evocrus@gmail.com

Lokasi Iklan

Info lebih lanjut kirim email ke evocrus@gmail.com

Showing posts with label Devexpress. Show all posts
Showing posts with label Devexpress. Show all posts

Wednesday, July 22, 2015

Change Cell Color Based By Cell Value Using Devexpress Xtragrid on VB.NET

In some case when we load data from database to grid, we want to change backcolor/forecolor on some cell depends by its value. like this pic below:

Change cell backcolor/forecolor based by cell value
The point is to get the user attention in some value that needs to be look, in this case I use xtragrid from devexpress component, So here its code:

Imports DevExpress.XtraGrid.Views.Grid 
'-----
Dim View As GridView = sender  
     If e.Column.FieldName = "slsh_Keluar" Then  
       Dim _sklrVal As Integer = View.GetRowCellValue(e.RowHandle, View.Columns("slsh_Keluar"))  
       If _sklrVal <> 0 Then  
         e.Appearance.BackColor = Color.Red  
         e.Appearance.ForeColor = Color.Yellow  
         'e.Appearance.BackColor2 = Color.Yellow  
       End If  
     End If  
     If e.Column.FieldName = "slsh_masuk" Then  
       Dim _smskVal As Integer = View.GetRowCellValue(e.RowHandle, View.Columns("slsh_masuk"))  
       If _smskVal <> 0 Then  
         e.Appearance.BackColor = Color.Red  
         e.Appearance.ForeColor = Color.Yellow  
       End If  
     End If  

Good Luck..



Wednesday, July 1, 2015

Looping Each Item in RibbonControl Devexpress

Jika anda mendesain tampilan menu form menggunakan ribbonForm dari devexpress anda tentunya akan menghadapi situasi dimana anda tidak ingin semua menu bisa diakses oleh user tertentu, anda ingin membatasi hak menu per user.

Bagi anda yang terbiasa dengan menu standar bawaan VB.NET tentunya hal ini bukanlah hal yang sulit, akan tetapi bagaimana dengan anda yang masih baru dengan devexpress.

Berikut saya sertakan source code looping ribbon control dimulai dari ribbonPageCategory, ribbonGroup, ribbonItem, ribbonItem di dalam subitem.

Source Code dalam C#
 using DevExpress.XtraBars;  
 using DevExpress.XtraBars.Ribbon;  
 private void simpleButton1_Click(object sender, EventArgs e)  
 {  
    foreach (RibbonPage page in ribbonControl1.Pages) {  
      foreach (RibbonPageGroup group in page.Groups) {  
         foreach (var link in group.ItemLinks) {  
           BarItemLink barItemLink = link as BarItemLink;  
           foreach (BarItemLink baritemlink in group.ItemLinks) {  
              baritemlink.Visible = true;  
           }  
           BarSubItemLink barSubItemLink = link as BarSubItemLink;  
           if (barSubItemLink != null) {  
              foreach (BarItemLink itemLink in barSubItemLink.Item.ItemLinks) {  
                BarButtonItem barButtonItem = itemLink.Item as BarButtonItem;  
                if(barButtonItem != null)  
                   itemLink.Visible = false;  
              }  
           }  
         }  
      }  
    }  
 }  

Source Code dalam VB.NET
 Imports DevExpress.XtraBars  
 Private Sub simpleButton1_Click(sender As Object, e As EventArgs)  
    For Each page As RibbonPage In ribbonControl1.Pages  
      For Each group As RibbonPageGroup In page.Groups  
         For Each link As var In group.ItemLinks  
           Dim barItemLink__1 As BarItemLink = TryCast(link, BarItemLink)  
           For Each baritemlink__2 As BarItemLink In group.ItemLinks  
              baritemlink__2.Visible = True  
           Next  
           Dim barSubItemLink As BarSubItemLink = TryCast(link, BarSubItemLink)  
           If barSubItemLink IsNot Nothing Then  
              For Each itemLink As BarItemLink In barSubItemLink.Item.ItemLinks  
                Dim barButtonItem As BarButtonItem = TryCast(itemLink.Item, BarButtonItem)  
                If barButtonItem IsNot Nothing Then  
                   itemLink.Visible = False  
                End If  
              Next  
           End If  
         Next  
      Next  
    Next  
 End Sub  

Semoga Membantu.