Home Forums WinForms controls Xceed Grid for WinForms Regarding comboboxeditor

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16980 |

    Hi,

    I need to get the item in the combobox should be highlighted.For suppose if Iam having two tables namely employee,department iam displaying employee table iam adding another column to the app name departmentname from the department table that departmentname cell is acomboboxeditor i need to get the values in the combobox of departmentname from department table iam getting that but the problem is when on the form load I need to get the departmentname of that particular employee displayed in the combobox cell.Here is the code below

     

    Dim

    simpleComboBoxEditor As New ComboBoxEditor(ds, “Employee2”, “Departmentname”, “%Departmentname%”)

    simpleComboBoxEditor.TemplateControl.BorderStyle = EnhancedBorderStyle.Fixed3D

    SetWinComboBoxStyle(simpleComboBoxEditor.TemplateControl)

    simpleComboBoxEditor.TemplateControl.DropDownSize =

    New Size(150, 150)

    GridControl1.Columns(

    “Departmentname”).CellEditorManager = simpleComboBoxEditor

    GridControl1.Columns(

    “Departmentname”).CellViewerManager = New ComboBoxViewer(ds, “Employee2”, “Departmentname”, “%Departmentname%”)

    Imported from legacy forums. Posted by yeswanth (had 2629 views)

    User (Old forums)
    Member
    Post count: 23064

    How are the two tables linked?  Normally, in the employee table, you should have some kind of value ID (Let’s call it DepartmentNumber) that identify the department, and in the Department table, you would have two columns, one being the value ID and the other the string name.  What you would do then is to have the grid bound on that value ID of the Employee table for the Department column, and the ComboBoxEditor of that column bound to the value ID of the Department Table for the ValueMember, and to the string name for the DisplayFormat.

    e.g.:

          //Bind the grid to the Employees table, which will create an DepartmentNumber column that you can rename to DepartmentName
          gridControl1.SetDataBinding( this.northwindDataSet, “Employees” );
          gridControl1.Columns[ “DepartmentNumber” ].Title = “DepartmentName”;

          //Editor bound to the Departments table on the same field name, that is DepartmentNumber
          ComboBoxEditor comboEditor = new ComboBoxEditor( this.northwindDataSet, “Departments”, “DepartmentNumber”, “%DepartmentName%” );
          gridControl1.Columns[ “DepartmentNumber” ].CellEditorManager = comboEditor;

          //Idem for the Viewer
          ComboBoxViewer comboViewer = new ComboBoxViewer( this.northwindDataSet, “Departments”, “DepartmentNumber”, “%DepartmentName%” );
          gridControl1.Columns[ “DepartmentNumber” ].CellViewerManager = comboViewer;

     

    Imported from legacy forums. Posted by André (had 2413 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi,

    Iam getting an exception here .The code is

    Dim

    strselect As String

    strselect =

    “select * from Employee2”

    Dim ds As New DataSet

    Dim dap As New SqlDataAdapter(strselect, con)

    dap.Fill(ds,

    “Employee2”)

    GridControl1.SetDataBinding(ds,

    “Employee2”)

    Dim simplecomboboxeditor As New ComboBoxEditor(ds, “Department3”, “Departmentid”, “%Departmentname%”)

    simplecomboboxeditor.TemplateControl.BorderStyle = EnhancedBorderStyle.Fixed3D

    SetWinComboBoxStyle(simplecomboboxeditor.TemplateControl)

    simplecomboboxeditor.TemplateControl.DropDownSize =

    New Size(150, 150)

    GridControl1.Columns(

    “Departmentid”).CellEditorManager = simplecomboboxeditor

    GridControl1.Columns(

    “Departmentid”).CellViewerManager = New ComboBoxViewer(ds, “Department3”, “Departmentid”, “%Departmentname%”)

    I am getting an exception that a “childlist cannot be created for field “department3“”

    Imported from legacy forums. Posted by yeswanth (had 518 views)

    User (Old forums)
    Member
    Post count: 23064

    [quote user=”yeswanth”]

    “childlist cannot be created for field “department3“”

    [/quote]

    Is “department3” a field in the Employee2 table, or is it a table?  If it is a field, this will not work.  If it is a table, I don’t see where you fill the dataset with the data of this table.

    e.g.:

        dap.Fill( ds, “Department3” )

     

    Imported from legacy forums. Posted by André (had 2381 views)

    User (Old forums)
    Member
    Post count: 23064

    Department3 is a table eventhough iam not filling the data it showing that exception.please take a look this entire code.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Dim strselect As String

    strselect =

    “select * from synemployees”

    Dim ds As New DataSet

    Dim dap As New SqlDataAdapter(strselect, con)

    dap.Fill(ds,

    “synemployees”)

    GridControl1.SetDataBinding(ds,

    “synemployees”)

     

    Dim simplecomboboxeditor As New Editors.ComboBoxEditor(ds, “Department3”, “Departmentid”, “%Departmentname%”)

    simplecomboboxeditor.TemplateControl.BorderStyle = EnhancedBorderStyle.Fixed3D

    SetWinComboBoxStyle(simplecomboboxeditor.TemplateControl)

    simplecomboboxeditor.TemplateControl.DropDownSize =

    New Size(150, 150)

    GridControl1.Columns(

    “Departmentid”).CellEditorManager = simplecomboboxeditor

    Dim simplecomboboxviewer As New Viewers.ComboBoxViewer(ds, “Department3”, “Departmentid”, “%Departmentname%”)

    GridControl1.Columns(

    “Departmentid”).CellViewerManager = New Viewers.ComboBoxViewer

    End Sub

    Imported from legacy forums. Posted by yeswanth (had 2486 views)

    User (Old forums)
    Member
    Post count: 23064

    You must fill the data from that table also, not just form the employee table, and there must be a relationship in the DB between those 2 tables.

    Imported from legacy forums. Posted by André (had 3589 views)

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.