Solved

Need to change datagrid cell values programatically

Posted on 2004-10-29
185 Views
Last Modified: 2010-04-23
On the Mouse Up event, I ask the user if they want to automatically update the values in this row.  If they say yes, I want to change various cell values and display those changes in the grid.
I assume I have to change the table and refresh the grid.  I am not getting any errors but I don't see the updates in the grid.  My dataset contains 3 tables.  The last one is the one bound to the datagrid.  Here is my code.

If Result = DialogResult.Yes Then
                Dim intRow As Integer = DataGrid1.CurrentRowIndex
                DsReqUpd14.Tables(2).Rows(intRow)(2) = Date.Today.ToString()
                DataGrid1.Refresh()
 End If
0
Question by:RuthD2004
    2 Comments
     
    LVL 7

    Assisted Solution

    by:kGenius
    Your code doesn't accept the changes.

    This should be your code (I thought, haven't checked it)

    If Result = DialogResult.Yes Then
                    Dim intRow As Integer = DataGrid1.CurrentRowIndex
                    DsReqUpd14.Tables(2).Rows(intRow)(2) = Date.Today.ToString()
                   
                    'AcceptChanges, accept the changes !!
                    DsReqUpd14.AcceptChanges()
                   
                    DataGrid1.Refresh()
     End If

    Hope it 'll help
    kGenius
    0
     
    LVL 4

    Accepted Solution

    by:
    Or you can do this:

    me.DataGrid1.Item(me.DataGrid1.CurrentRowIndex, here_the_number_of_the_column)

    in here_the_number_of_the_column you can put the column number of the columns that you want to change its value:

    me.DataGrid1.Item(me.DataGrid1.CurrentRowIndex, 0) = "Hello"
    me.DataGrid1.Item(me.DataGrid1.CurrentRowIndex, 1) = "Bye"

    in this code you will put the values "Hello" and "Bye" in the cell that you wanted, and then you can update your table.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    884 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now