Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > Datagridview


Reply
 
Thread Tools Display Modes
  #1  
Old 06-29-2012, 10:08 AM
dr223 dr223 is offline
Centurion
 
Join Date: Feb 2009
Posts: 105
Default Datagridview


Hi,

At run time, if I Click ToolBarButton1 - I can still check/uncheck the checkbox at Cell 3 even if the value is "Old" at Cell 2.

Thanks

Code:
If e.Button Is ToolBarButton1 Then
Dim irowNo As Integer
            For irowNo = 0 To DgvPracExcl.Rows.Count - 1
                If DgvPracExcl.Rows(irowNo).Cells(2).ToString() = "old" Then
                    DgvPracExcl.Rows(irowNo).Cells(3).ReadOnly = True
                Else
                    DgvPracExcl.Rows(irowNo).Cells(3).ReadOnly = False
                End If

            Next irowNo

   End If
Reply With Quote
  #2  
Old 07-02-2012, 02:55 PM
NFITC1 NFITC1 is offline
Centurion
 
Join Date: Apr 2006
Posts: 100
Default

From my experience with DGVs, altering cells like that doesn't work as intended. It's probably better to clone the whole row, alter the cell the way you want it to be, then reinsert the row at the same index that you removed it.

Code:
If e.Button Is ToolBarButton1 Then
    For Each dvgr As DataGridViewRow In DgvPracExcl.Rows
            If dvgr.Cells(2).ToString() = "old" Then
                dvgr.Cells(3).ReadOnly = True
            Else
                dvgr.Cells(3).ReadOnly = False
            End If
        DgvPracExcl.Rows.Insert(dvgr.Index, dvgr)
        '.Insert inserts the row where the index points to and shifts the other rows down.
        'Don't forget to remove the row that got shifted down because it's identical to the one you just inserted minus the readonly cell
        DgvPracExcl.Rows.RemoveAt(dvgr.Index + 1) 
    Next
End If
I can't guarantee that that'll work, but I think it has a better chance than altering the cells while they're in the DGV. You might even have to change the row template of the row you clone.
Reply With Quote
  #3  
Old 08-13-2012, 02:02 AM
andrewpattinson andrewpattinson is offline
Newcomer
 
Join Date: Aug 2012
Posts: 1
Default

Use Row.Update() method .This method is used to change row position during sorting.When event-driven model is used , the grid gets relevant Property Changed and List Changed notifications.
dapfor. com/en/net-suite/net-grid/tutorial/data-filtering
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->