BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
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
any answer or replay pl
anyone have answer or replay pl
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.