views:

288

answers:

3

I have the DGV bound to data and all the other controls properly. What I am trying to do now is update a PictureBox based on the contents of the data row. The picture is not a part of the bound data, its always available on the web. I have a function that will build the url string to a webserver with the images I need.

The problem is that I can figure out the proper event. Mouse Click works perfectly but doesnt allow for keyboard selection (ie bound fields update but pictureBox does not). RowEnter/RowLeave both leave me with the picture from the row that was previously selected, never the current row.

Any insight would be appreciated.

A: 

Wild Guess: OnRowDataBound

If you want access to a row (and its columns) as its being bound to the grid, use the event above.

You question states that your problem is that you do know the event, or do you mean you dont know the event ?

EDIT: If you want this behavior to occur client side(i.e. when selecting a row theres no postback), then some javascript like an onclick event handler on the entire row,(tr) or place a checkbox in the first column and use an onlick for that.

Otherwise you if you want a postback everytime you select a row, then you can use an event such as OnSelectedIndexChanged or the build in commands that come with the DGV.

Jobo
Won't work. He wants the picture to be updated when the row is selected, not data bound.
Dillie-O
A: 

Another wild guess: SelectionChanged

steve
A: 

EDIT: Realized you wanted it to happen when you selected a row..

MyGrid.RowEnter += new DataGridViewCellEventHandler(MyGrid_RowEnter );

void MyGrid_RowEnter(object sender, DataGridViewCellEventHandlere)
{
    if (0 > e.RowIndex) return;

    //TODO: Do whatever with your image here..
}
Quintin Robinson