Results 1 to 5 of 5

Thread: A few datagrid questions...

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,633

    A few datagrid questions...

    I hate binding, it for beginners and muppets...well it was in VB6 anyways.
    It seems like binding is the norm in .NET...well whoopy doo.

    I have a DS and I bind it to a datagrid.

    1) How do I make some columns invisible?
    2) How can I set it to select a full row and not just a cell?
    3) How do I autosize the columns to fit the grid. It looks silly otherwise if the cols do not match the grid width.
    4) How can I stop the datagrid automatically adding a new row? I don't want it to be editable.

    Why does .NET suck so much at doing VERY simple things?

    Woka

  2. #2
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036
    Hi

    1) by setting its width at Zero


    4) datagrid.readonly=true


    Regards
    Jorge
    "The dark side clouds everything. Impossible to see the future is."

  3. #3
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036
    Hi

    2)

    Private Sub dataGrid1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dataGrid1.MouseUp

    Dim pt = New Point(e.X, e.Y)

    Dim hti As DataGrid.HitTestInfo = dataGrid1.HitTest(pt)

    If hti.Type = DataGrid.HitTestType.Cell Then

    dataGrid1.CurrentCell = New DataGridCell(hti.Row, hti.Column)

    dataGrid1.Select(hti.Row)

    End If

    End Sub

    3) Don't how.

    Regards
    Jorge
    "The dark side clouds everything. Impossible to see the future is."

  4. #4

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,633
    Cheers for you help.

    How can I set the col width = 0? It's bound. Is there an event I must trap?

    In VB6 when you set the border style to be flat single, it's only 1 px wide. In .NET it seems to be 2. This is to fat. How can I make it 1?

    Woka

  5. #5
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036
    Hi

    VB Code:
    1. Dim tableStyle As DataGridTableStyle
    2. tableStyle = New DataGridTableStyle
    3. tableStyle.MappingName = "artenc"
    4.  Me.DataGrid2.TableStyles.Clear()
    5. Me.DataGrid2.TableStyles.Add(tableStyle)
    6.  
    7.  
    8. Me.DataGrid2.TableStyles("artenc").GridColumnStyles(0).Width = 30
    9. Me.DataGrid2.TableStyles("artenc").GridColumnStyles(1).Width = 30

    Please note the mappingname must have the same name the datatable you used to bind the datagrid.

    Regards
    Jorge
    "The dark side clouds everything. Impossible to see the future is."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width