Datagrid dispaly


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: Datagrid dispaly

  1. #1
    Join Date
    Dec 2005
    Posts
    4

    Question Datagrid dispaly

    I have 2 comboboxes(outside of datagrid) and 1 datagrid.Based on the two combobox selections,the selected items on both should display in a single datagrid.
    My problem is when i select the first combobox item,it displays properly on the datagrid.when i select the second combobox item it should append in the datagrid.instead it replaces the first column.even if i select the other columns in the first combobox it should also append not replace.
    How do you display more than one column from the same combobox in a datagrid
    Regs
    Seetal

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    I assume that the DataGrid is bound to a dataset of some kind, correct? If so, you should create a single dataset based on the selections in the two combo boxes, then bind the dataset to the grid.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Dec 2005
    Posts
    4

    Datagrid Display

    I have not yet connected to the database.I need the selected items from combobox to display in datagrid as a column header .

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    OK. Please post the code you're using to assign the combobox values to the datagrid. Thanks!
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  5. #5
    Join Date
    Dec 2005
    Posts
    4

    Datagrid Display

    Private Sub UiCboClient_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UiCboClient.SelectedIndexChanged

    Dim mytable As DataTable
    myTable = New DataTable("Client_Details")
    myTable.Columns.Add(New DataColumn(UiCboClient.Text, GetType(String)))
    Me.GrdBusiness.SetDataBinding(myTable, "")
    Me.GrdBusiness.RetrieveStructure()


    End Sub

  6. #6
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    OK. You're binding the DataGrid to a DataTable (myTable) containing the column headings, but you're creating a new DataTable each time the user selects an item from a combobox, so your DataGrid will only ever have a single column heading.

    Try this: Declare myTable at the Class level, rather than inside a Sub or Function:

    Dim mytable As New DataTable("Client_Details")

    Then, in the SelectedIndexChanged event, do this:

    myTable.Columns.Add(New DataColumn(UiCboClient.Text, GetType(String)))
    Me.GrdBusiness.SetDataBinding(myTable, "")
    Me.GrdBusiness.RetrieveStructure()

    That will add a column to the DataTable without recreating it each time.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  7. #7
    Join Date
    Dec 2005
    Posts
    4

    Datagrid Display

    Thanks A lot Phil.
    It works Great.I Appreciate.

Similar Threads

  1. Help with .NET DataGrid features
    By software_develo in forum .NET
    Replies: 4
    Last Post: 01-17-2009, 07:17 AM
  2. Replies: 0
    Last Post: 09-02-2005, 07:28 PM
  3. Replies: 0
    Last Post: 06-05-2003, 09:30 PM
  4. Is there guidelines for proper use of DataGrid
    By Thomas Eyde in forum .NET
    Replies: 8
    Last Post: 08-01-2002, 06:43 PM
  5. Threading and the .NET Datagrid
    By McCleud in forum .NET
    Replies: 2
    Last Post: 08-01-2002, 10:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center