Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / September 2006

Tip: Looking for answers? Try searching our database.

Programmatically checking a DataGridViewCheckboxCell

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
CJM - 28 Sep 2006 23:36 GMT
I can't for the life of me figure out how to check or uncheck a cell
programmatically. I've looked in Lutz's reflector to see how the
control is doing it and it calling an UpdateButtonState method that I
don't have access to.

This must be super simple but I'm just missing something.

Any help would be GREATLY appreciated :)
Dave Sexton - 29 Sep 2006 02:56 GMT
Hi,

If the DataGridView is data-bound just set the value in the associated property or column of your data source to "true".

Signature

Dave Sexton

>I can't for the life of me figure out how to check or uncheck a cell
> programmatically. I've looked in Lutz's reflector to see how the
[quoted text clipped - 4 lines]
>
> Any help would be GREATLY appreciated :)
Tim Van Wassenhove - 01 Oct 2006 00:26 GMT
> I can't for the life of me figure out how to check or uncheck a cell
> programmatically. I've looked in Lutz's reflector to see how the
> control is doing it and it calling an UpdateButtonState method that I
> don't have access to.
>
> This must be super simple but I'm just missing something.

public Form1()
{
    InitializeComponent();
    this.dataGridView1.Rows.Add();
}

private void button1_Click( object sender, EventArgs e )
{
    bool value = (bool)( this.dataGridView1.Rows[0].Cells[0].Value ?? false );
    this.dataGridView1.Rows[0].Cells[0].Value = !value;
}

Signature

Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be>


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.