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.
Unfortunately, activation email could not send to your email. Please try again.

GridControl ComboBox events change or close up

Thread ID:

Created:

Updated:

Platform:

Replies:

114269 Nov 9,2013 04:58 AM Nov 23,2013 12:51 PM Windows Forms 3
loading
Tags: GridControl
reda
Asked On November 9, 2013 04:58 AM

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

reda
Replied On November 11, 2013 02:14 AM

any answer or replay pl


reda
Replied On November 13, 2013 06:43 AM

anyone have  answer or replay pl



Praveena P [Syncfusion]
Replied On November 23, 2013 12:51 PM

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.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;