How do I set the value of an unbound DataGridView cell?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: How do I set the value of an unbound DataGridView cell?

  1. #1
    Join Date
    May 2002
    Posts
    1,717

    How do I set the value of an unbound DataGridView cell?

    I need to build a Form with a DataGridView. I do not intend to use this grid to connect to any database. I simply need to know how to write some string or value (whatever) to a specific cell.

    I have spent hours fooling with this (VS 2005 SE) and searching the Internet without any luck. I could waste alot of time and space posting code that doesnt work and the associated error messages, but I think I will spare you that for now.

    If anyone can help me accomplish this task, I would greatly appreciate it.

    Thanks

    Mike
    mpliam

  2. #2
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    1,080

    Re: How do I set the value of an unbound DataGridView cell?

    You do it exactly as you've asked the question: you get the cell and you set its Value property. You can get a reference to the cell via the grid's Item property or any number of other ways. It sounds to me like you've spent hours fooling around and searching the Internet without spending a minute doing the thing you should have done first of all: reading the documentation for the DataGridView class. The MSDN library has plenty of reference and howto information on the DataGridView, including some dedicated to unbound grids, in which case you have to explicitly add columns and rows before any cells exist.
    Tutorials: Home & Learn | Start VB.NET | Learn VB.NET | C# Station | GotDotNet | Games in VB.NET 101 Samples: 2002 | 2003 | 2005 | More .NET 2.0 (VB.NET, C#) Articles: VB.NET | C# | ASP.NET | MoreFree Components: WFC | XPCC | ElementsEx | VBPP | Mentalis | ADO.NET/MySQL | VisualStyles | Charting (NPlot, ZedGraph) | iTextSharp (PDF) | SDF (CF) ● Free Literature: VB 2005 (eBook) | VB6 to VB.NET (eBook) | MSDN Magazine (CHM format) ● Bookmarks: MSDN | WinForms .NET | ASP.NET | WinForms FAQ | WebForms FAQ | GotDotNet | Code Project | DevBuzz (CF) ● Code Converter: C#/VB.NET | VB.NET/C# | VS 2005 add-in

  3. #3
    Join Date
    May 2002
    Posts
    1,717

    Re: How do I set the value of an unbound DataGridView cell?

    Thanks. You have such a pleasant way of putting things.

    I'll do as you suggest and won't ask about it again.

    FWIW, my article was a C# article. Sorry if I used this forum "inappropriately".

    Mike
    mpliam

  4. #4
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    1,080

    Re: How do I set the value of an unbound DataGridView cell?

    I'm all about the information, not the presentation.
    Tutorials: Home & Learn | Start VB.NET | Learn VB.NET | C# Station | GotDotNet | Games in VB.NET 101 Samples: 2002 | 2003 | 2005 | More .NET 2.0 (VB.NET, C#) Articles: VB.NET | C# | ASP.NET | MoreFree Components: WFC | XPCC | ElementsEx | VBPP | Mentalis | ADO.NET/MySQL | VisualStyles | Charting (NPlot, ZedGraph) | iTextSharp (PDF) | SDF (CF) ● Free Literature: VB 2005 (eBook) | VB6 to VB.NET (eBook) | MSDN Magazine (CHM format) ● Bookmarks: MSDN | WinForms .NET | ASP.NET | WinForms FAQ | WebForms FAQ | GotDotNet | Code Project | DevBuzz (CF) ● Code Converter: C#/VB.NET | VB.NET/C# | VS 2005 add-in

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center