Results 1 to 4 of 4

Thread: datagridview (again)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    datagridview (again)

    i still have question about datagridview

    1.how can set the width dynamically of the datagrid pointer or the record selector i can't find it's properties to hide or set the width.

    2. example i have these i load the data in datagridview:
    column1
    2
    4
    2
    5

    the sum is 15
    label1.text = sum of column1

    how?
    *****************
    VB6,PHP,VS 2005

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: datagridview (again)

    1. I assume you mean the row headers down the left-hand side of the grid. That would be the RowHeaderWidth property.

    2. I'm going to assume that your data is coming from a DataTable. If that's incorrect please let me know. Firstly you should bind your DataTable to a BindingSource, then bind that to the grid. To get the sum of the values in Column1 of the DataTable you'd do this:
    C# Code:
    1. int sum = (int)myDataTable.Compute("SUM(Column1)", myBindingSource.Filter);
    That will sum all the rows and only the rows that are displayed in the grid. If you have set the Filter property of the BindingSource to exclude some rows from the grid, that code will allow for that and not include those rows in the calculation.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    Re: datagridview (again)

    OH MY GOD!, I didn't try the "RowHeaderVisible = false" because of its name (ROWHEADER) its better to name it ROWPOINTER or SELECTOR
    and i thought the Record Selector is not listed in the porperty.

    yes mydata are on data table... i'll try what you suggested, i trust you...

    anyways, glad to hear from you again. TNX!
    *****************
    VB6,PHP,VS 2005

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: datagridview (again)

    Given that the grid has column headers it is consistent to use the term "row headers" too.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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