Tampilkan postingan dengan label GridControl. Tampilkan semua postingan
Tampilkan postingan dengan label GridControl. 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]

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]

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 Object, ByVal 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]