DataGridViewImageColumn DataGridViewTextBoxColumn DataGridViewColumn HELP

Answered
0
0

Which of these DGV controls has the WORKING  .VALUE property

that I can manipulate PROGRAMMATICALLY in the  CellFormatting method CONDITIONALLY ?

I believe this round I’m trying a plain DataGridViewColumn

 
if (pbNoteId > 0)   // this value is based upon harvesting an Id from a not visible neighboring column 
{
//this.dgvPricebooks.Rows[iRowIndex][colIndexNoteImage].Style.DataSourceNullValue = null;
//this.dgvPricebooks.Rows[iRowIndex][colIndexNoteImage].Style.BackgroundImageSource = Properties.Resources.note.ToString();
this.dgvPricebooks.Rows[iRowIndex][colIndexNoteImage].Value = Properties.Resources.note;
}
else
{
//this.dgvPricebooks.Rows[iRowIndex][colIndexNoteImage].Style.BackgroundImageSource = null;
this.dgvPricebooks.Rows[iRowIndex][colIndexNoteImage].Value = null;
}

 

The Grid loads all rows with the notes Icon ,  you will get the icon displayed after clicking in the cell

but so what the scrolling will mess that up as well because it repeatedly re runs the CellFormatting method

  • Christian Programmer
    Correction one test loads with all cells displaying icons another test displays icon only after clicking cell as shown in image attachment
  • You must to post comments
Best Answer
0
0

CellFormatting is to set the formatting of the cell, not to change the value. Use the e.Value and e.CellStyle to adjust the formatting.

https://docs.wisej.com/api/wisej.web/lists-and-grids/datagridview/wisej.web.datagridviewcellformattingeventargs

If the column is an image column set the image (either a string or an image) to e.Value. If you have different requirement send a small test case showing what you need to do and what is the issue you are encountering.

  • You must to post comments
0
0

–COMMENT—  &  FOLLOW UP Question please              is it OK to manually invoke this render method for each row ?
– I didn’t want to make a fresh question for naught,
please & thank you

Greetings all, I did this — >   [ Image attached ]

[
if (iRowIndex >= 0 && iColIndex == colIndexNoteImage) // Image Column r.e. display
{
// DYNAMIC DISPLAY OF Notes Image WHEN Notes column has valid NoteId
pbNoteId = // from some other cell
if (pbNoteId > 0)
{
e.CellStyle.BackgroundImage = Properties.Resources.note;
e.CellStyle.BackgroundImageAlign = ContentAlignment.MiddleCenter;
e.CellStyle.BackgroundImageLayout = ImageLayout.BestFit;
e.CellStyle.Render();
}
else
{ e.CellStyle.BackgroundImage = null; }
}
]
to attempt to address my inconsistent DGV cell image response with scrolling
& its seems to work. I could not locate any documentation WiseJ or MSFT regarding this
method off of e.CellStyle.Render();
the UI is still a bit slow — is it OK to manually invoke this render method for each row ?
Or am i causing an additional needless performance hit ?
DataGridViewCellFormattingEventArgs.CellStyle.Render();

 

 

  • You must to post comments
0
0

–COMMENT—  &  FOLLOW UP Question please              is it OK to manually invoke this render method for each row ?
– I didn’t want to make a fresh question for naught,
please & thank you

Greetings all, I did this — >   [ Image attached ]

[
if (iRowIndex >= 0 && iColIndex == colIndexNoteImage) // Image Column r.e. display
{
// DYNAMIC DISPLAY OF Notes Image WHEN Notes column has valid NoteId
pbNoteId = // from some other cell
if (pbNoteId > 0)
{
e.CellStyle.BackgroundImage = Properties.Resources.note;
e.CellStyle.BackgroundImageAlign = ContentAlignment.MiddleCenter;
e.CellStyle.BackgroundImageLayout = ImageLayout.BestFit;
e.CellStyle.Render();
}
else
{ e.CellStyle.BackgroundImage = null; }
}
]
to attempt to address my inconsistent DGV cell image response with scrolling
& its seems to work. I could not locate any documentation WiseJ or MSFT regarding this
method off of e.CellStyle.Render();
the UI is still a bit slow — is it OK to manually invoke this render method for each row ?
Or am i causing an additional needless performance hit ?
DataGridViewCellFormattingEventArgs.CellStyle.Render();

 

 

  • You must to post comments
0
0

–COMMENT—  &  FOLLOW UP Question please              is it OK to manually invoke this render method for each row ?
– I didn’t want to make a fresh question for naught,
please & thank you

Greetings all, I did this — >   [ Image attached ]

[
if (iRowIndex >= 0 && iColIndex == colIndexNoteImage) // Image Column r.e. display
{
// DYNAMIC DISPLAY OF Notes Image WHEN Notes column has valid NoteId
pbNoteId = // from some other cell
if (pbNoteId > 0)
{
e.CellStyle.BackgroundImage = Properties.Resources.note;
e.CellStyle.BackgroundImageAlign = ContentAlignment.MiddleCenter;
e.CellStyle.BackgroundImageLayout = ImageLayout.BestFit;
e.CellStyle.Render();
}
else
{ e.CellStyle.BackgroundImage = null; }
}
]
to attempt to address my inconsistent DGV cell image response with scrolling
& its seems to work. I could not locate any documentation WiseJ or MSFT regarding this
method off of e.CellStyle.Render();
the UI is still a bit slow — is it OK to manually invoke this render method for each row ?
Or am i causing an additional needless performance hit ?
DataGridViewCellFormattingEventArgs.CellStyle.Render();

 

 

  • You must to post comments
0
0

–COMMENT—  &  FOLLOW UP Question please              is it OK to manually invoke this render method for each row ?
– I didn’t want to make a fresh question for naught,
please & thank you

Greetings all, I did this — >   [ Image attached ]

[
if (iRowIndex >= 0 && iColIndex == colIndexNoteImage) // Image Column r.e. display
{
// DYNAMIC DISPLAY OF Notes Image WHEN Notes column has valid NoteId
pbNoteId = // from some other cell
if (pbNoteId > 0)
{
e.CellStyle.BackgroundImage = Properties.Resources.note;
e.CellStyle.BackgroundImageAlign = ContentAlignment.MiddleCenter;
e.CellStyle.BackgroundImageLayout = ImageLayout.BestFit;
e.CellStyle.Render();
}
else
{ e.CellStyle.BackgroundImage = null; }
}
]
to attempt to address my inconsistent DGV cell image response with scrolling
& its seems to work. I could not locate any documentation WiseJ or MSFT regarding this
method off of e.CellStyle.Render();
the UI is still a bit slow — is it OK to manually invoke this render method for each row ?
Or am i causing an additional needless performance hit ?
DataGridViewCellFormattingEventArgs.CellStyle.Render();

 

 

  • You must to post comments
0
0

–COMMENT—  &  FOLLOW UP Question please              is it OK to manually invoke this render method for each row ?
– I didn’t want to make a fresh question for naught,
please & thank you

Greetings all, I did this — >   [ Image attached ]

[
if (iRowIndex >= 0 && iColIndex == colIndexNoteImage) // Image Column r.e. display
{
// DYNAMIC DISPLAY OF Notes Image WHEN Notes column has valid NoteId
pbNoteId = // from some other cell
if (pbNoteId > 0)
{
e.CellStyle.BackgroundImage = Properties.Resources.note;
e.CellStyle.BackgroundImageAlign = ContentAlignment.MiddleCenter;
e.CellStyle.BackgroundImageLayout = ImageLayout.BestFit;
e.CellStyle.Render();
}
else
{ e.CellStyle.BackgroundImage = null; }
}
]
to attempt to address my inconsistent DGV cell image response with scrolling
& its seems to work. I could not locate any documentation WiseJ or MSFT regarding this
method off of e.CellStyle.Render();
the UI is still a bit slow — is it OK to manually invoke this render method for each row ?
Or am i causing an additional needless performance hit ?
DataGridViewCellFormattingEventArgs.CellStyle.Render();

 

 

  • You must to post comments
0
0

–COMMENT—  &  FOLLOW UP Question please              is it OK to manually invoke this render method for each row ?
– I didn’t want to make a fresh question for naught,
please & thank you

Greetings all, I did this — >   [ Image attached ]

[
if (iRowIndex >= 0 && iColIndex == colIndexNoteImage) // Image Column r.e. display
{
// DYNAMIC DISPLAY OF Notes Image WHEN Notes column has valid NoteId
pbNoteId = // from some other cell
if (pbNoteId > 0)
{
e.CellStyle.BackgroundImage = Properties.Resources.note;
e.CellStyle.BackgroundImageAlign = ContentAlignment.MiddleCenter;
e.CellStyle.BackgroundImageLayout = ImageLayout.BestFit;
e.CellStyle.Render();
}
else
{ e.CellStyle.BackgroundImage = null; }
}
]
to attempt to address my inconsistent DGV cell image response with scrolling
& its seems to work. I could not locate any documentation WiseJ or MSFT regarding this
method off of e.CellStyle.Render();
the UI is still a bit slow — is it OK to manually invoke this render method for each row ?
Or am i causing an additional needless performance hit ?
DataGridViewCellFormattingEventArgs.CellStyle.Render();

 

 

  • You must to post comments
0
0

OK   I had to use BackgroundImage  property  and its still not clean the scrollbar makes it wonky the top of the grid doesn’t refresh .

The BackgroundImageSource  property accepted the string from resource but didn’t work for me

if (pbNoteId > 0)
{
//e.CellStyle.BackgroundImageSource = Properties.Resources.note.ToString();
e.CellStyle.BackgroundImage = Properties.Resources.note;
}
else
{
//e.CellStyle.BackgroundImageSource = null;
e.CellStyle.BackgroundImage = null;
}

Thank you

  • You must to post comments
0
0

“If the column is an image column set the image (either a string or an image) to e.Value. ”

Is that to be performed in the CellFormatting method and is it specifically for the DataGridViewImageColumn  ?

Please & Thank you   I grabbed someones sample from here and it is setting     e.CellStyle.BackgroundImageSource

i was just about to test that set to a string  Properties.Resources.note.ToString();

  • You must to post comments
Showing 9 results
Your Answer

Please first to submit.