Some Datagrid Problems

MarkItZero

Freshman
Joined
Apr 10, 2003
Messages
43
Location
under the desk in my office
Hello,
I will admit that I am a lousy VB.Net programmer, but when the boss says get it done, it seems I dont have much choice.

I am creating a windows program using data from an Access database. I thought my best bet would be to use datagrids on my form for inserting, editing and deleting data from the tables. When I used the datagrid wizard to create my form I expected I would find a lot of the same functionality that I would find if I just opened the table in Access. Sadly this is not the case.

I especially wanted to be able to copy and paste rows just like I would in Access or Excel. But I have no idea where to start.

I also need to find a way to add combo boxes to my datagrid.

Lastly, I have added a checkbox column to the datagrid, but it is behaving strangely. Sometimes when I click the box, nothing happens. Other times I will click the box and a dim grey check mark will appear instead of the usual bold black mark.

This is the code that I used to set my datagrid properties everything else on the form was generated by the wizard...

Code:
  'Set Datagrid Properties
        'New Table Style
        Dim TSeditEquip As New DataGridTableStyle
        'Table Style Properties
        With TSeditEquip
            .MappingName = "Equipment"
        End With

        'Declare Each Column of DG
        Dim col1 As New DataGridTextBoxColumn
        Dim col2 As New DataGridTextBoxColumn
        Dim col3 As New DataGridTextBoxColumn
        Dim col4 As New DataGridBoolColumn

        'Column Properties
        With col1
            .HeaderText = "Equip Code"
            .MappingName = "EquipCode"
            .Width = 100
            .TextBox.MaxLength = 15
            .NullText = String.Empty
        End With
        With col2
            .HeaderText = "Type"
            .MappingName = "EquipType"
            .Width = 150
        End With
        With col3
            .HeaderText = "Description"
            .MappingName = "Description"
            .Width = 250
            .TextBox.MaxLength = 25
            .NullText = String.Empty
        End With
        With col4
            .HeaderText = "Inactive"
            .MappingName = "Inactive"
            .Width = 60
        End With

        'Add Columns to DataStyle
        TSeditEquip.GridColumnStyles.AddRange(New DataGridColumnStyle() {col1, col2, col3, col4})
        'Add DataStyle to DG
        grdEquipment.TableStyles.Add(TSeditEquip)

Any suggestions for any of my problems would be greatly appreciated.

Thanks!
 
Who doesn't have problems wit DataGrid???

First - If you have budget and/or the project really worths it and/or you have more projects where you need a grid implementation, buy a third party one, I usually sugest XtraGrid from www.devexpress.com.

Next - Copy/Paste rows isn't an embeded featuro on grids.
Databound grids can display alot complex data structures that the just can't automaticly "know" how to duplicate.
What you can, and must, do is to implement the feature on the datasource, reflecting the changes on the presentation layer, in this case, on the datagrid.
An idea is to add some buttons, i.e. Copy, Paste, PasteTo, MoveTo... as desired, manipulate the data on the datasource, i.e. a DataTable, and reflect the changes on the datagrid (if they just don't reflect themselves automaticly).

Alex :p
 
Back
Top