Results 1 to 9 of 9

Thread: [RESOLVED] Remove Blank Row In Datagrid Control

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    Beach Alley
    Posts
    86

    Resolved [RESOLVED] Remove Blank Row In Datagrid Control

    Is there a possiblity by any chance that a blank row in datagrid will be remove ?

    Let's say the datagrid has this kind of info :

    Column 1 | Column 2 | Column 3

    User 1 NY 290-5542
    Null Null Null
    User 2 CA 350-5555


    Lets assume that row 2 has a data and i inputed the data in row 3, however i change my mind i deleted the data in row 2 and that will leave row 2 blank. I s there a method where i can remove the row 2.

    The first thing come up on my mind was use a timer wherein it runs all the time. But it seems a bad idea though.

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

    Re: Remove Blank Row In Datagrid Control

    First up, is it really a DataGrid or is it actually a DataGridView? Secondly, is the grid bound or unbound, i.e. have you set its DataSource? If it's bound, what is it bound to?
    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
    Lively Member
    Join Date
    Aug 2006
    Location
    Beach Alley
    Posts
    86

    Re: Remove Blank Row In Datagrid Control

    Datagrid or Datagridview are they two different control ?
    Well the control name is Datagridview i guess ?.
    Bound or Unbound ? You mean if i bind it with a datatable or dataset ? if it is, no the control will just accept a user input, i can input on a textbox column, check and uncheck on checkbox column.

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

    Re: Remove Blank Row In Datagrid Control

    If the grid is unbound then removing a row is pretty much as you would expect: the Rows collection has both Remove and RemoveAt methods, allowing you specify a row or a row index.
    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

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    Beach Alley
    Posts
    86

    Re: Remove Blank Row In Datagrid Control

    Using the timer is not a problem ?. Because the first thing came up on my mind was set a for loop in the timer and check if the row is a full blank and then delete it. Or there's a professional way on doing that ?

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

    Re: Remove Blank Row In Datagrid Control

    I don't understand why a Timer would be needed. Who is deleting the data in the first place? If it's you in code then you would just remove the row there in code instead. If it's the user then they can simply use the Delete key to delete a row.
    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

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    Beach Alley
    Posts
    86

    Re: Remove Blank Row In Datagrid Control

    I'm just assuming that most of the user will just leave some of rows blank and never delete it. If you take a look in post #1 the scenario. Is there an event of datagrid whereun it can trigger the blank row?

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

    Re: Remove Blank Row In Datagrid Control

    I would say that is an invalid assumption. Why would a user go to the trouble of deleting each individual field in a row when they can just delete the row? Maybe there are some people out there who would do it but, frankly, they must be idiots. Anyone with any sense would see that leaving a row blank means they have a blank row and, if they don't want a blank row, they should delete it. I've worked on many projects containing grids and never once has that been an issue.
    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

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    Beach Alley
    Posts
    86

    Re: Remove Blank Row In Datagrid Control

    I guess you have the point. Well thanks jm.

    by the way jm I saw a thread of yours wherein you managed to make a flip/flop vista in forms, what thread is it ?

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