We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

GridControl ComboBox events change or close up

hi
i use GridControl ComboBox to load data from table in data base
i want when i change the in ComboBox or close up the combobox
load anthother data from another table and put them in an other col i have tryed but the data on the ComboBox  when i filtter not as it shown

==========================

 Imports System.Data.OleDb
'Imports Syncfusion.Windows.Forms.Grid.Grouping
Imports Syncfusion.Windows.Forms
Imports Syncfusion.Windows.Forms.Grid
Imports Microsoft.Win32

Public Class Form1
    Private con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source =" & Application.StartupPath & "\databind.mdb")
    Private cmd As New OleDbCommand()

    Private da As New OleDbDataAdapter()
    Private ds As New DataSet()
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load


        con.Open()
        With cmd

            .Connection = con
            .CommandType = CommandType.TableDirect
            .CommandText = "select*from Categories"

        End With
        da.SelectCommand = cmd
        da.Fill(ds, "Categories")

        '

        Me.GridControl1.ColStyles(2).CellType = GridCellTypeName.GridListControl
        Me.GridControl1.ColStyles(2).DropDownStyle = Syncfusion.Windows.Forms.Grid.GridDropDownStyle.Exclusive
        Me.GridControl1.ColStyles(2).DataSource = ds.Tables(0)
        Me.GridControl1.ColStyles(2).DisplayMember = "CategoryName"
        Me.GridControl1.ColStyles(2).ValueMember = "CategoryID"

      
        Me.GridControl1.ColStyles(2).IsAutoComplete()

        Me.GridControl1.CurrentCell.ShowDropDown()


        Me.GridControl1.Model.Options.WrapCellBehavior = GridWrapCellBehavior.WrapRow

    End Sub
  

 =====================

here the problem

==================

    Private Sub GridControl1_CurrentCellChanged(sender As Object, e As EventArgs) Handles GridControl1.CurrentCellChanged
        If Me.GridControl1.CurrentCell.ColIndex = 2 Then
            'con.Open()


        
            Dim rd As OleDbDataReader

            Dim sql2 As String
            Dim _testo As String
            Dim GridListControl_text As String
            GridListControl_text = Me.GridControl1(Me.GridControl1.CurrentCell.RowIndex, 2).CellValue
            sql2 = "select*from Categories where(Categories.CategoryName='" & GridListControl_text & "')"
            cmd = New OleDbCommand(sql2, con)


            rd = cmd.ExecuteReader
            If rd.HasRows Then

                If rd.Read Then
                    Me.GridControl1(Me.GridControl1.CurrentCell.RowIndex, 1).CellValue = rd.Item("CategoryID")
                    '
                End If

            Else
                Me.GridControl1(Me.GridControl1.CurrentCell.RowIndex, 1).CellValue = GridListControl_text '"FilterQuery"
            End If
        End If

    End Sub

   


   


End Class

============

i Attach project pl modify  it



invoice_syc_65d8618a.rar

3 Replies

RE reda November 11, 2013 07:14 AM UTC

any answer or replay pl



RE reda November 13, 2013 11:43 AM UTC

anyone have  answer or replay pl




PP Praveena P Syncfusion Team November 23, 2013 05:51 PM UTC

Hi Reda,

We deeply regret for the inconvenience caused with delay.

I am afraid I am unclear with your query. With my understandings, I have provided a suggestion.

In the sample provided you have used CurrentCellActivated event which is unnecessary as the CurrentCellShowedDroppedDown event can be used for customizing the GridListControl. Please refer the below link for your reference. 

Link: http://help.syncfusion.com/ug/windows%20forms/grid/default.htm%23!Documents/formattingdropdownli.htm

And as I guess your requirement is when the selection changes , load newly selected value of column1 in dropdownlist  to the gridcontrol column1 cell ,  then use the below code in ModelQueryCellInfo event instead of CurrentCellChangedEvent.

Code:

  Dim rd As OleDbDataReader

        Dim sql2 As String

        Dim _testo As String

        Dim GridListControl_text As String

        GridListControl_text = Me.GridControl1(Me.GridControl1.CurrentCell.RowIndex, 2).FormattedText

        sql2 = "select*from Categories where(Categories.CategoryName='" & GridListControl_text & "')"

        cmd = New OleDbCommand(sql2, con)

        rd = cmd.ExecuteReader

        If rd.HasRows Then

                    If rd.Read Then

                Me.GridControl1(e.RowIndex,1).CellValue = rd.Item("CategoryID")                        End If

        Else

            Me.GridControl1(Me.GridControl1.CurrentCell.RowIndex,1).CellValue = GridListControl_text

       End If

Please let me know if you have concerns.

Regards,

Praveena.


Loader.
Live Chat Icon For mobile
Up arrow icon