Click here to Skip to main content
15,913,115 members
Home / Discussions / C#
   

C#

 
Questionchange picture of image controll in gridvie in windows application???? [not solved yet...] Pin
mr.mohsen8-Oct-09 1:16
mr.mohsen8-Oct-09 1:16 
AnswerRe: change picture of image controll in gridvie???? Pin
Atif Ali Bhatti8-Oct-09 1:40
Atif Ali Bhatti8-Oct-09 1:40 
GeneralRe: change picture of image controll in gridvie???? Pin
mr.mohsen8-Oct-09 2:34
mr.mohsen8-Oct-09 2:34 
AnswerRe: change picture of image controll in gridvie in windows application???? Pin
Henry Minute8-Oct-09 4:18
Henry Minute8-Oct-09 4:18 
GeneralRe: change picture of image controll in gridvie in windows application???? Pin
mr.mohsen8-Oct-09 7:30
mr.mohsen8-Oct-09 7:30 
GeneralRe: change picture of image controll in gridvie in windows application???? Pin
Henry Minute8-Oct-09 8:41
Henry Minute8-Oct-09 8:41 
GeneralRe: change picture of image controll in gridvie in windows application???? Pin
mr.mohsen8-Oct-09 9:05
mr.mohsen8-Oct-09 9:05 
GeneralRe: change picture of image controll in gridvie in windows application???? Pin
Henry Minute8-Oct-09 9:44
Henry Minute8-Oct-09 9:44 
Well I hadn't tested it although there was no reason that it shouldn't work, so I built a test app and it works exactly as I thought.

Here is the code for the entire form:
public partial class ImageColumnTestForm : Form
{
    private Bitmap start = ImageCellTest.Properties.Resources.START; // I am getting the images from the apps resources
    private Bitmap stop = ImageCellTest.Properties.Resources.STOP;   // 'ImageCellTest' is the Namespace that I used.

    public ImageColumnTestForm()
    {
        InitializeComponent();
    }

    private void ImageColumnTestForm_Load(object sender, EventArgs e)
    {
        DataGridViewRow newRow = null;
        DataGridViewTextBoxCell textCell = null;
        DataGridViewImageCell imgCell = null;

        for (int i = 0; i < 5; i++)
        {
            newRow = new DataGridViewRow();
            textCell = new DataGridViewTextBoxCell();
            newRow.Cells.Add(textCell);
            imgCell = new DataGridViewImageCell();
            newRow.Cells.Add(imgCell);
            textCell.Value = "Text " + i.ToString();
            imgCell.Value = start;
            imgCell.Tag = true;
            this.dataGridView1.Rows.Add(newRow);
        }
    }

    private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
    {
        // Try to load it as a DataGridViewImageCell
        DataGridViewImageCell img = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex] as DataGridViewImageCell;
        // If that works, we have the right cell
        if (img != null)
        {
            if ((bool)img.Tag)
            {
                // if it is true then we are started, so stop
                img.Value = stop;
                img.Tag = false;
                // HERE DO ANYTHING ELSE REQUIRED FOR STOPPING e.g. this.timer1.Stop;
            }
            else
            {
                // if it is false then we are stopped, so start
                img.Value = start;
                img.Tag = true;
                // HERE DO ANYTHING ELSE REQUIRED FOR STARTING e.g. this.timer1.Start;
            }
        }
    }
}


As you can see I simply copied the CellClick code from my previous reply to you and all that I changed was to add the semi-colon to the first line, as I am sure that you did. Blush | :O

This is just a standard form with a datagridview on it and it works just fine.

Henry Minute

Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”

GeneralRe: change picture of image controll in gridvie in windows application???? Pin
mr.mohsen8-Oct-09 12:24
mr.mohsen8-Oct-09 12:24 
QuestionCreating a Designer Add-In for Visual Studio Pin
RobertFall8-Oct-09 0:30
RobertFall8-Oct-09 0:30 
AnswerRe: Creating a Designer Add-In for Visual Studio Pin
Richard MacCutchan8-Oct-09 0:44
mveRichard MacCutchan8-Oct-09 0:44 
GeneralRe: Creating a Designer Add-In for Visual Studio Pin
RobertFall8-Oct-09 0:48
RobertFall8-Oct-09 0:48 
GeneralRe: Creating a Designer Add-In for Visual Studio Pin
Richard MacCutchan8-Oct-09 1:08
mveRichard MacCutchan8-Oct-09 1:08 
GeneralRe: Creating a Designer Add-In for Visual Studio Pin
RobertFall8-Oct-09 1:43
RobertFall8-Oct-09 1:43 
QuestionComparing for Columns Pin
Yonathan11117-Oct-09 23:25
professionalYonathan11117-Oct-09 23:25 
AnswerRe: Comparing for Columns Pin
Pete O'Hanlon8-Oct-09 0:02
mvePete O'Hanlon8-Oct-09 0:02 
AnswerRe: Comparing for Columns Pin
dan!sh 8-Oct-09 0:41
professional dan!sh 8-Oct-09 0:41 
Questionforms loading events!!! Pin
faheemnadeem7-Oct-09 23:14
faheemnadeem7-Oct-09 23:14 
AnswerRe: forms loading events!!! Pin
Christian Graus7-Oct-09 23:18
protectorChristian Graus7-Oct-09 23:18 
GeneralRe: forms loading events!!! Pin
faheemnadeem7-Oct-09 23:27
faheemnadeem7-Oct-09 23:27 
AnswerRe: forms loading events!!! Pin
Alan N8-Oct-09 0:11
Alan N8-Oct-09 0:11 
GeneralRe: forms loading events!!! Pin
Mycroft Holmes8-Oct-09 1:10
professionalMycroft Holmes8-Oct-09 1:10 
GeneralRe: forms loading events!!! Pin
Alan N8-Oct-09 2:00
Alan N8-Oct-09 2:00 
GeneralRe: forms loading events!!! Pin
Dave Kreskowiak8-Oct-09 4:02
mveDave Kreskowiak8-Oct-09 4:02 
AnswerRe: forms loading events!!! Pin
Luc Pattyn8-Oct-09 1:18
sitebuilderLuc Pattyn8-Oct-09 1:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.