C#
--
Questions
--
Followers
Top Experts
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
var Mins = yourDataTable.AsEnumerable().Max(row => Convert.ToInt32(row["MERENI"]));
var Maxs = yourDataTable.AsEnumerable().Min(row => Convert.ToInt32(row["MERENI"]));
Txt.Value = (string) Mins






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
int min = 0;
for (int i = 0; i <= dotaz4DataGridView.Rows.Count - 1; i++)
{
if (i == 0)
{
min = int.Parse(dotaz4DataGridView.Rows[i].Cells[0].Value.ToString());
}
if (min > int.Parse(dotaz4DataGridView.Rows[i].Cells[0].Value.ToString()))
{
min = int.Parse(dotaz4DataGridView.Rows[i].Cells[0].Value.ToString());
}
}
textBox3.Text = min.ToString();
for (int i = 0; i <= dotaz4DataGridView.rows.Count - 1; i++)
{
for (int j = 0; j <= dotaz4DataGridView.Columns.Count - 1; j++)
{
if (i == 0)
{
min = int.Parse(dotaz4DataGridView.Rows[i][j].Cells[0].Value.ToString());
}
if (min > int.Parse(dotaz4DataGridView.Rows[i][j].Cells[0].Value.ToString()))
{
min = int.Parse(dotaz4DataGridView.Rows[i][j].Cells[0].Value.ToString());
}
}
}
textBox3.Text = min.ToString();

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
I think this is what you may be looking for. This assumes that the values in the row are all strings
// From each row in the DataTable find the min and max value of the row
var results = (from DataRow row in dt.AsEnumerable()
select new
{
Min = row.ItemArray.Where((r, idx) => idx != 0).Min(c => Int32.Parse(c.ToString())),
Max = row.ItemArray.Where((r, idx) => idx != 0).Max(c => Int32.Parse(c.ToString()))
});
// The variable results returns an Anonymous type holding two values Min and Max value of each row
foreach (var minMax in results)
{
// And to access the Min and Max of the Anonymous type you can do as below
Console.WriteLine("Min = {0}", minMax.Min);
Console.WriteLine("Max = {0}\n", minMax.Max);
}
It is possible to write min / max value from datagrid (from one row) into textbox?






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Try this to see if it works for you.
var results = (from row in dataGridView1.Rows.Cast<DataGridViewRow>()
where !row.IsNewRow
let cells = row.Cells.Cast<DataGridViewCell>()
let Min = cells.Where((c, idx) => idx != 0).Min(c => Int32.Parse(c.Value.ToString()))
let Max = cells.Where((c, idx) => idx != 0).Max(c => Int32.Parse(c.Value.ToString()))
select new
{
Min,
Max
}).ToList();
foreach (var minMax in results)
{
// And to access the Min and Max of the Anonymous type you can do as below
Console.WriteLine("Min = {0}", minMax.Min);
Console.WriteLine("Max = {0}\n", minMax.Max);
}

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Did the code I last posted which queries the DataGridView, did that work?
If it did not please post the code you used to load the data into the DataGridView.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void dotaz4BindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.dotaz4BindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.dB_KROUTAKUDataSet);
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'dB_KROUTAKUDataSet.dotaz4' table. You can move, or remove it, as needed.
this.dotaz4TableAdapter.Fill(this.dB_KROUTAKUDataSet.dotaz4);
}
}
}






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
var results = (from row in dataGridView1.Rows.Cast<DataGridViewRow>()
where !row.IsNewRow
let cells = row.Cells.Cast<DataGridViewCell>()
let Min = cells.Where((c, idx) => idx != 0).Min(c => Int32.Parse(c.Value.ToString()))
let Max = cells.Where((c, idx) => idx != 0).Max(c => Int32.Parse(c.Value.ToString()))
select new
{
Min,
Max
}).ToList();
foreach (var minMax in results)
{
// And to access the Min and Max of the Anonymous type you can do as below
Console.WriteLine("Min = {0}", minMax.Min);
Console.WriteLine("Max = {0}\n", minMax.Max);
}

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
can you zip up the complete project so I can see if I can figure out what is happening and post it to a site where I can download it from such as Google Docs or some other.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Hello Fernando,
How to modify a code so I can also use decimal numbers?
Please open a new question for this new requirement and when I get some time today I will look at it.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
let Min = cells.Where((c, idx) => idx != 1).Min(c => Convert.ToDecimal(c.Value.ToString()))
let Max = cells.Where((c, idx) => idx != 1).Max(c => Convert.ToDecimal(c.Value.ToString()))
Work it
By changing this section of the two lines from this, (c, idx) => idx != 0, to this, (c, idx) => idx != 1, you are removing the column 1_MERENI from the calculation and adding the column PROVEDL_MERENI to the calculation. Is this what you want to be doing?
C#
--
Questions
--
Followers
Top Experts
C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).



