C# 调整datagridview单元格中位图图像的大小
仍然存在调整图像大小的问题 使用c sharp.net 4.0 winforms和MS Visual Studio 2010 以下是我目前拥有的代码:C# 调整datagridview单元格中位图图像的大小,c#,image,image-resizing,C#,Image,Image Resizing,仍然存在调整图像大小的问题 使用c sharp.net 4.0 winforms和MS Visual Studio 2010 以下是我目前拥有的代码: private void ShowArrow() { foreach (DataGridViewRow paretoRow in ParetoGrid.Rows) { if ((paretoRow.Cells["Pareto6"].Value != null) &&
private void ShowArrow()
{
foreach (DataGridViewRow paretoRow in ParetoGrid.Rows)
{
if ((paretoRow.Cells["Pareto6"].Value != null) && (Convert.ToInt32(paretoRow.Cells["CurrentPareto"].Value) < (Convert.ToInt32(paretoRow.Cells["NewPareto"].Value))))
{
downArrow.Width = 2;
downArrow.Height = 2;
paretoRow.Cells["p1"].Value = downArrow;
}
else if ((paretoRow.Cells["Pareto6"].Value != null) && (Convert.ToInt32(paretoRow.Cells["CurrentPareto"].Value) > (Convert.ToInt32(paretoRow.Cells["NewPareto"].Value))))
{
//ParetoGrid.Rows[paretoRow.Index].DefaultCellStyle.BackColor = Color.LightGreen;
paretoRow.Cells["p1"].Value = upArrow;
}
}
}
private void ShowArrow()
{
foreach(ParetoGrid.Rows中的DataGridViewRow ParetRow)
{
if((paretrow.Cells[“Pareto6”].Value!=null)&&(Convert.ToInt32(paretrow.Cells[“CurrentPareto”].Value)<(Convert.ToInt32(paretrow.Cells[“NewPareto”].Value)))
{
向下箭头。宽度=2;
向下箭头。高度=2;
Paretrow.单元格[“p1”]。值=向下箭头;
}
else if((paretrow.Cells[“Pareto6”].Value!=null)&&(Convert.ToInt32(paretrow.Cells[“CurrentPareto”].Value)>(Convert.ToInt32(paretrow.Cells[“NewPareto”].Value)))
{
//ParetoGrid.Rows[ParetRow.Index].DefaultCellStyle.BackColor=Color.LightGreen;
Paretrow.单元格[“p1”]。值=向上箭头;
}
}
}
但是当我试图编辑图像大小时,它会说图像是只读的?
这是调整图像大小的好方法吗?还是有更好的办法
非常感谢您可以检查图像对象的“只读”属性并继续操作。 假设变量为BitmapImage myImage
bool isReadOnly = myImage.IsSealed;
还有另一个方法叫做SetValue。希望这有帮助
您可以检查图像对象的“只读”属性并继续操作。 假设变量为BitmapImage myImage
bool isReadOnly = myImage.IsSealed;
还有另一个方法叫做SetValue。希望这有帮助
如果您有图像对象,可以尝试以下操作:
事实上,这不是一个单行程序解决方案,但它很接近。您可能希望事先生成已调整大小的图像,并在以后使用。如果您有图像对象,可以尝试以下操作: 事实上,这不是一个单行程序解决方案,但它很接近。您可能希望事先生成调整大小的图像,然后再使用它