Tampilkan postingan dengan label DevExpress. Tampilkan semua postingan
Tampilkan postingan dengan label DevExpress. Tampilkan semua postingan

GridView Colum Filter Via Code

Posted On // Leave a Comment
GridView1.ActiveFilterString = "[Category] = 3 AND [Discontinued] = false"

Select grid view row by code, programatically filter row devexpress grid view

[Read more]

DoubleClick pada GridControl DevExpress

Posted On // Leave a Comment

Jika kita menggunakan hanya event DoubleClick, maka yang terjadi adalah dimanapun anda double click (bahkan di luar baris pada grid) maka event akan di eksekusi. berikut adalah agar event di kerjakan jika kita double click pada baris gridControl DevExpress

Private Sub GridView1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GridView1.DoubleClick

        Dim view As DevExpress.XtraGrid.Views.Grid.GridView = sender
        Dim pt As Point = view.GridControl.PointToClient(Control.MousePosition)

        If view.CalcHitInfo(pt).InRow Or view.CalcHitInfo(pt).InRowCell Then
            MsgBox("double click in row")
        End If


    End Sub
[Read more]

Import Data Dari Excell ke Grid

Posted On // Leave a Comment


Berikut adalah cara untuk import data dari file CSV ke grid pada vb.net. Grid yang saya gunakan adalah GridControl dari DevExpress.


            Dim strfilename As String = BEIFileLocation.EditValue
            Dim tmpstream As StreamReader = File.OpenText(strfilename)
            Dim strlines() As String
            strlines = tmpstream.ReadToEnd().Split(Environment.NewLine)

            For x = 1 To UBound(strlines) - 1
                Dim _strRows() As String = Split(strlines(x).ToString, ";")

                Dim _dr As DataRow
                _dr = _ds.TmpTblKontak.NewRow
                _dr.Item("isValid") = False
                _dr.Item("IDCabang") = _strRows(0).ToString.Trim
                _dr.Item("IDDept") = _strRows(1).ToString.Trim
                _dr.Item("IDdivisi") = _strRows(2).ToString.Trim
                _dr.Item("IDPosisi") = _strRows(3).ToString.Trim
                _dr.Item("IDGol") = _strRows(4).ToString.Trim
                _dr.Item("NIK") = _strRows(5).ToString.Trim
                _dr.Item("NoKTP") = _strRows(6).ToString.Trim
                _dr.Item("Nama") = _strRows(7).ToString.Trim
                _dr.Item("HP") = _strRows(8).ToString.Trim
                _dr.Item("TempatLahir") = _strRows(9).ToString.Trim
                _dr.Item("TglLahir") = _strRows(10).ToString.Trim
                _dr.Item("Alamat") = _strRows(11).ToString.Trim
                _dr.Item("Kota") = _strRows(12).ToString.Trim
                _dr.Item("Email") = _strRows(13).ToString.Trim
                _dr.Item("Status") = _strRows(14).ToString.Trim
                _ds.TmpTblKontak.Rows.Add(_dr)

            Next

            GridControl1.DataSource = _ds.TmpTblKontak

[Read more]

Menangani Even DoubleClick Pada Devexpress GridView

Posted On // Leave a Comment

Penanganan double click pada DevExpress GridView ternyata tidak semudah yang saya bayangkan, karena harus memvalidasi apakah tempat kita doubleclick merupakan bagian dari suatu kolom/baris atau tidak.

setelah beberapa menit tanya ke mbah google, akhirnya nemu disini. Berikut script nya


Private Sub gridView1_DoubleClick(ByVal sender As Object, ByVal e As EventArgs) Handles GridView1.DoubleClick

        Dim view As GridView = CType(sender, GridView)

        Dim pt As Point = view.GridControl.PointToClient(Control.MousePosition)

        DoRowDoubleClick(view, pt)

    End Sub

    Private Shared Sub DoRowDoubleClick(ByVal view As GridView, ByVal pt As Point)

        Dim info As GridHitInfo = view.CalcHitInfo(pt)
        If info.InRow OrElse info.InRowCell Then

            Dim colCaption As String = ""
            If info.Column Is Nothing Then
                colCaption = "N/A"
            Else
                colCaption = info.Column.GetCaption
            End If

            MessageBox.Show(String.Format("Double click on row: {0}, column: {1}", info.RowHandle, colCaption))

        End If

    End Sub
[Read more]

Update Database From DevExpress GridControl

Posted On // Leave a Comment
After spend hours in google, finaly I got answer about how to update database when my GridControl is updated or inserted a new row. the code is really simple, but not as simple as find the right keyword to google it ;).

So here's the few code


Private Sub __UpdateMasterJasa(ByVal grid As DevExpress.XtraGrid.GridControl)

        Try
            'save the latest changes
            Dim view As ColumnView = grid.FocusedView
            If Not (view.PostEditor() And view.UpdateCurrentRow) Then Return

            'Update the database's Jasa table to which SQLDataAdapter DAMstJasa is connected
            DAMstJasa.Update(DS.Tables("MstJasa"))

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

    End Sub

Enjoy ;)
[Read more]

Confirm Row Deletion When Using the Devexpress Gridview EmbeddedNavigator

Posted On // Leave a Comment


  1. To do this, I need to handle the ButtonClick event of the embedded navigator.
  2. select the grid control, in the events list, I expand the EmbeddedNavigator node and doubleclick to create a handle for the ButtonClick event.
  3.  Since the Embedded Navigator is part of the XtraEditors Library, I’m first going to add a 
  4. reference to the DevExpress.XtraEditors namespace.
  5. Now I’m going to add the following code to the event handler
Private Sub GridControl1_EmbeddedNavigator_ButtonClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraEditors.NavigatorButtonClickEventArgs) Handles GridControl1.EmbeddedNavigator.ButtonClick
        If e.Button.ButtonType = NavigatorButtonType.Remove Then
            If XtraMessageBox.Show(_LookAndFeel, "Anda yakin mau menghapus data?", Me.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.No Then
                e.Handled = True
            End If
        End If
    End Sub

[Read more]

Set LookupEdit Default Value

Posted On // Leave a Comment

Dim r As Integer = LUEMerek.Properties.GetDataSourceRowIndex(Me.LUEMerek.Properties.Columns("Nama"), "Honda")
        LUEMerek.EditValue = Me.LUEMerek.Properties.GetDataSourceValue(LUEMerek.Properties.ValueMember, r)
[Read more]

Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.

Posted On // Leave a Comment
"Concurrency violation: the UpdateCommand affected 0 of the expected 1 records."

I got that message when i was try to update database when my DevExpress GridControl changed. Heres the wrong code:

Private Sub AdvBandedGridView1_RowUpdated(ByVal sender As System.Object, ByVal e As DevExpress.XtraGrid.Views.Base.RowObjectEventArgs) Handles AdvBandedGridView1.RowUpdated
        If AdvBandedGridView1.UpdateCurrentRow Then
            Try
                DAUniFix.Update(DsUniFix)
            Catch ex As Exception
                XtraMessageBox.Show(_LookAndFeel, ex.Message, Me.Text)
            End Try
        End If
    End Sub

To fix this error, make sure your table has primary key and simply add two line of syntax as shown below


Private Sub AdvBandedGridView1_RowUpdated(ByVal sender As System.Object, ByVal e As DevExpress.XtraGrid.Views.Base.RowObjectEventArgs) Handles AdvBandedGridView1.RowUpdated
        If AdvBandedGridView1.UpdateCurrentRow Then
            Try
                Me.Validate()
                Me.UniFixBindingSource.EndEdit()
                DAUniFix.Update(DsUniFix)
            Catch ex As Exception
                XtraMessageBox.Show(_LookAndFeel, ex.Message, Me.Text)
            End Try
        End If
    End Sub

[Read more]

Change Devexpress Gridcontrol Font Size

Posted On // Leave a Comment
Some component devexpress properties are unable to change such as font type and size on GridControl, groupControl etc. So the only way to change it's properties is through the code. here's one line code





Public Sub New()
DevExpress.Utils.AppearanceObject.DefaultFont = New Font("Courier New", 10)
InitializeComponent()
End Sub

[Read more]

hide devexpress lookup column

Posted On // Leave a Comment
I try to use SQLServer Stored Procedure to load DataTable into DevExpress LookupEdit. Here's the syntax:

Dim dtTipe As New DataTable

        With _SqlCommand

            .CommandText = "mstTipe_SELECT_id_Nama_WHERE_Merek_Honda"

            .Parameters.Clear()

            _SQLReader = .ExecuteReader

        End With

        dtTipe.Load(_SQLReader)

        With lookupTipe

            .Properties.DataSource = dtTipe

            .Properties.ValueMember = "Nama"

            .Properties.DisplayMember = "Nama"

            .Properties.PopupWidth = 250

        End With

        _SQLReader.Close()


the result of syntax above is:












The problem is, I want to hide the "ID" column because user don't care about it.

Here's the two lines addition code to hide the "ID" column


  Dim dtTipe As New DataTable
        With _SqlCommand
            .CommandText = "mstTipe_SELECT_id_Nama_WHERE_Merek_Honda"
            .Parameters.Clear()
            _SQLReader = .ExecuteReader
        End With
        dtTipe.Load(_SQLReader)
        With lookupTipe
            .Properties.DataSource = dtTipe
            .Properties.PopulateColumns()
            .Properties.Columns("ID").Visible = False
            .Properties.ValueMember = "Nama"
            .Properties.DisplayMember = "Nama"
            .Properties.PopupWidth = 250
        End With
        _SQLReader.Close()













You can't hide the column before populate it. So, all you have to do is populate the colum then you can set visibility to false.
[Read more]

Set Devexpress LookupEdit Datasource use msSQL Stored Procedure

Posted On // Leave a Comment
Sub __OpenRsTipe()
        Dim dtTipe As New DataTable
        With _SqlCommand
            .CommandText = "mstTipe_SELECT_id_Nama_WHERE_Merek_Honda"
            .Parameters.Clear()
            _SQLReader = .ExecuteReader
        End With
        dtTipe.Load(_SQLReader)
        With LookUpTipe
            .Properties.DataSource = dtTipe
            .Properties.ValueMember = "Nama"
            .Properties.DisplayMember = "Nama"
            .Properties.PopupWidth = 250
        End With
        _SQLReader.Close()
    End Sub
[Read more]

Get Detail Rows Value pada DevExpress Grid Control

Posted On // Leave a Comment
Private Sub gridViewLaporan_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles gridViewLaporan.MouseUp
        If e.Button = Windows.Forms.MouseButtons.Right Then
            Dim _gridView As GridView = gridLaporan.FocusedView
            MsgBox(_gridView.GetFocusedDisplayText)
        End If
    End Sub
[Read more]

How to show a context menu for grid rows

Posted On // Leave a Comment
[C#]
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;

private void gridView1_ShowGridMenu(object sender,DevExpress.XtraGrid.Views.Grid.GridMenuEventArgs e) {
GridView view = sender as GridView;
GridHitInfo hitInfo = view.CalcHitInfo(e.Point);
if(hitInfo.InRow) {
view.FocusedRowHandle = hitInfo.RowHandle;
ContextMenu1.Show(view.GridControl, e.Point);
}
}
[VB.NET]
Imports DevExpress.XtraGrid.Views.Grid

Private Sub GridView1_ShowGridMenu(ByVal sender As ObjectByVal e As
DevExpress.XtraGrid.Views.Grid.GridMenuEventArgs) Handles GridView1.ShowGridMenu
   Dim View As GridView = CType(sender, GridView)
   Dim HitInfo As ViewInfo.GridHitInfo
   HitInfo = View.CalcHitInfo(e.Point)
   If HitInfo.InRow Then
       View.FocusedRowHandle = HitInfo.RowHandle
       ContextMenu1.Show(View.GridControl, e.Point)
   End If
End Sub
Attachments
[Read more]

LookupEdit : How to fill repository LookupEdit on Devexpress

Posted On // Leave a Comment
Dim dsNomorRangka As New DataSet
        Dim daNomorRangka As SqlDataAdapter = New SqlDataAdapter("crmFollowUpSalesDelivery_lstNomorRangka", SQLConnection)

        With daNomorRangka
            .SelectCommand.CommandType = CommandType.StoredProcedure
            .SelectCommand.Parameters.Clear()
            .SelectCommand.Parameters.Add("@CabangID", SqlDbType.NVarChar, 2).Value = o_getCabangID(cboCabangNama.EditValue)
        End With

        daNomorRangka.Fill(dsNomorRangka)

        With RepositoryLookupNomorRangka
            .DataSource = dsNomorRangka.Tables(0)
            .ValueMember = "NomorRangka"
            .DisplayMember = "NomorRangka"
        End With

        RepositoryLookupNomorRangka.PopupWidth = 500
        cboNomorRangka.Edit = Me.RepositoryLookupNomorRangka
[Read more]

Programmatically Set Devexpress AdvBandedGridView

Posted On // Leave a Comment
'Set Grid Column
Sub __SetGridColumn()
        Dim bandTransaksi = New DevExpress.XtraGrid.Views.BandedGrid.GridBand, _
            bandSuratJalan = New DevExpress.XtraGrid.Views.BandedGrid.GridBand, _
            bandDistribusi = New DevExpress.XtraGrid.Views.BandedGrid.GridBand, _
            bandDebitNote = New DevExpress.XtraGrid.Views.BandedGrid.GridBand, _
            bandKendaraan = New DevExpress.XtraGrid.Views.BandedGrid.GridBand, _
            bandValid = New DevExpress.XtraGrid.Views.BandedGrid.GridBand, _
            bandBatal = New DevExpress.XtraGrid.Views.BandedGrid.GridBand

        With gridPenjualanAdvBandedView
            .Bands.Clear()
            .Bands.AddRange(New DevExpress.XtraGrid.Views.BandedGrid.GridBand() _
                            {bandTransaksi, bandSuratJalan, bandDistribusi, bandDebitNote, bandKendaraan, bandValid, bandBatal})
            .GridControl = gridPenjualan
            .OptionsView.ColumnAutoWidth = False
            .Columns(0).DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom
            .Columns(0).DisplayFormat.FormatString = "dd-MMM-yyyy"
            .Columns(0).Caption = "Tanggal"
            .Columns(0).Width = 75

            With .OptionsView
                .ShowChildrenInGroupPanel = True
                .ShowColumnHeaders = True
                .ShowAutoFilterRow = True
            End With

            .GroupFooterShowMode = Views.Grid.GroupFooterShowMode.VisibleAlways

            'bandTransaksi.Fixed = Columns.FixedStyle.Left
            With .Columns(4)
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom
                .DisplayFormat.FormatString = "dd-MMM-yyyy"
                .Caption = "Tanggal"
                .Width = 75
            End With
            With .Columns(5)
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom
                .DisplayFormat.FormatString = "dd-MMM-yyyy"
                .Caption = "Nomor"
                .Width = 75
            End With
            With .Columns(6)
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom
                .DisplayFormat.FormatString = "dd-MMM-yyyy"
                .Caption = "Tanggal"
                .Width = 75
            End With
            With .Columns(7)
                .Caption = "Nomor"
                .Width = 75
            End With
            With .Columns(8)
                .Caption = "Tanggal"
                .Width = 75
            End With
            With .Columns(9)

                .Caption = "Nomor"
                .Width = 75
            End With
            With .Columns(10)
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom
                .DisplayFormat.FormatString = "dd-MMM-yyyy"
                .Caption = "Tgl. J. Tempo"
                .Width = 75
            End With

            .Columns(11).Visible = False

            With .Columns(17)
                .Caption = "Gross"
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
                .DisplayFormat.FormatString = "n0"
            End With
            With .Columns(18)
                .Caption = "Discount"
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
                .DisplayFormat.FormatString = "n0"
            End With
            With .Columns(19)
                .Caption = "DPP"
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
                .DisplayFormat.FormatString = "n0"
            End With
            With .Columns(20)
                .Caption = "PPN"
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
                .DisplayFormat.FormatString = "n0"
            End With
            With .Columns(21)
                .Caption = "Netto"
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
                .DisplayFormat.FormatString = "n0"
            End With
            With .Columns(22)
                .Caption = "Gross"
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
                .DisplayFormat.FormatString = "n0"
            End With
            With .Columns(23)
                .Caption = "Discount"
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
                .DisplayFormat.FormatString = "n0"
            End With
            With .Columns(24)
                .Caption = "DPP"
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
                .DisplayFormat.FormatString = "n0"
            End With
            With .Columns(25)
                .Caption = "PPN"
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
                .DisplayFormat.FormatString = "n0"
            End With
            With .Columns(26)
                .Caption = "Netto"
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
                .DisplayFormat.FormatString = "n0"
            End With
        End With

        With bandTransaksi
            .Caption = "Pembelian"
            .Columns.Add(gridPenjualanAdvBandedView.Columns(0))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(1))
            .Width = 200
        End With

        With bandSuratJalan
            .Caption = "Surat Jalan"
            .Columns.Add(gridPenjualanAdvBandedView.Columns(2))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(3))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(4))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(5))
            .Width = 500
        End With

        With bandDistribusi
            .Caption = "Distribusi"
            .Columns.Add(gridPenjualanAdvBandedView.Columns(6))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(7))
        End With

        With bandDebitNote
            .Caption = "Debit Note"
            .Columns.Add(gridPenjualanAdvBandedView.Columns(8))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(9))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(10))
        End With

        With bandKendaraan
            .Caption = "Kendaraan"
            .Columns.Add(gridPenjualanAdvBandedView.Columns(11))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(12))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(13))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(14))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(15))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(16))
        End With

        With bandValid
            .Caption = "Valid"
            .Columns.Add(gridPenjualanAdvBandedView.Columns(17))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(18))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(19))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(20))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(21))
            .Width = 350
        End With

        With bandBatal
            .Caption = "Batal"
            .Columns.Add(gridPenjualanAdvBandedView.Columns(22))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(23))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(24))
            .Width = 350
        End With
        gridPenjualanAdvBandedView.BestFitColumns()
    End Sub
[Read more]

DevExpress XtraPrinting Setting Header / Footer

Posted On // Leave a Comment
Dim phf As PageHeaderFooter = _
            TryCast(_PrintableComponentLink.PageHeaderFooter, PageHeaderFooter)
        phf.Header.Content.Clear()
[Read more]

DevExpress Create Group Summary

Posted On // Leave a Comment
From DevExpress

[Read more]

Get RepositoryItemLookUpEdit Row Value

Posted On // Leave a Comment
With RepositoryItemLookUpEditSearch
     MsgBox(.GetDataSourceValue("ID", .GetDataSourceRowIndex("Nama", _
     txtSearch.EditValue)).ToString)
End With

[Read more]

DevExpress set LookUpEdit Repository

Posted On // Leave a Comment
Berikut adalah syntax yang digunakan pada component DevExpress data Repository LookUpEdit

Dim dsNomorRangka As New DataSet
Dim daNomorRangka As SqlDataAdapter = New SqlDataAdapter("crmFollowUpSalesDelivery_lstNomorRangka", SQLConnection)

With daNomorRangka
.SelectCommand.CommandType = CommandType.StoredProcedure
      .SelectCommand.Parameters.Clear()
      .SelectCommand.Parameters.Add("@CabangID", SqlDbType.NVarChar, 2).Value = "21"
      .SelectCommand.Parameters.Add("@NomorRangka", SqlDbType.NVarChar, 20).Value = "MHRGD" ' cboNomorRangka.EditValue
End With

daNomorRangka.Fill(dsNomorRangka)

With RepositoryLookupNomorRangka
.DataSource = dsNomorRangka.Tables(0)
      .ValueMember = "NomorRangka"
      .DisplayMember = "NomorRangka"
End With
[Read more]

DevExpress : Mendapatkan Nilai SelectedIndex BarEditItem

Posted On // Leave a Comment
RepositoryItemCboCabangNama.Items.IndexOf(cboCabangNama.EditValue).ToString
[Read more]