15,117,549 members

# Comments by meenakshi syal (Top 11 by date)

meenakshi syal 22-Sep-14 6:53am View

no not yet
meenakshi syal 19-Sep-14 0:13am View

I have this problem and this is my code :

about datagrid view in c# calculating statistical calculations
See more: C#3.5
I am developing window application . Im importing few text files to datagridview1.
Its each colum contain about 220 rows .Now i want to calculate average of all the column in next datagridview2 .

after that want to transpose the datagridview2 average values vertically in next datagridview3
then next want to calculate the total count of datagridview3 values that we have transposed in the next datagridview4.

next now calculate the standard deviation of those average values
I have written this code Im listing
but in this code not getting the correct answer. pls correct it

public DataTable computedTable(DataTable dt)
{
DataTable avgtable = new DataTable();
List values = new List();
double value = 0.00;
double sumForMean = 0.00, bigSum = 0.00, mean = 0.00;
double stdDev = 0.00;
double minval = 0.00;
double maxval = 0.00;
bool b = true;
var meanrow = avgtable.NewRow();
var countrow = avgtable.NewRow();
var stddevrow = avgtable.NewRow();
var maxrow = avgtable.NewRow();
var minrow = avgtable.NewRow();
for (int col = 0; col < dt.Columns.Count; col++)
{
value = 0.00;
sumForMean = 0.00; bigSum = 0.00; mean = 0.00;
stdDev = 0.00;
maxval=0.00;minval=0.00;
for (int row = 0; row < dt.Rows.Count; row++)
{
}

// Calculate the total for the mean
for (int i = 0; i < values.Count; i++)
sumForMean += values[i];
// Calculate the mean
mean = sumForMean / values.Count;

// Calculate the total for the standard deviation
for (int i = 0; i < values.Count; i++)
bigSum += Math.Pow(values[i] - mean, 2);
// Now we can calculate the standard deviation
stdDev = Math.Sqrt(bigSum / (values.Count - 1));

//Now Calculate Max Value of each column
maxval = mean + this.Tvalue(double.Parse(values.Count.ToString())-1)*(stdDev/(Math.Sqrt(double.Parse(values.Count.ToString()))));
minval = mean - this.Tvalue(double.Parse(values.Count.ToString())-1) * (stdDev / (Math.Sqrt(double.Parse(values.Count.ToString()))));
if (b == true)
{

}
meanrow[col] = mean;
countrow[col] = values.Count.ToString();
stddevrow[col] =stdDev;
maxrow[col] = maxval;
minrow[col] = minval;
b = false;
values.Clear();
}

return avgtable;
}
meenakshi syal 9-Sep-13 0:49am View

Deleted
given is the code I'm using its working .....just I need code that how to export these values
from propertygrid to excel ?

meenakshi syal 9-Sep-13 0:48am View

Deleted
public class ImageStatisticsWindow : Content
{
private System.Windows.Forms.PropertyGrid propertyGrid;
private System.ComponentModel.Container components = null;
private SaveFileDialog saveFileDialog1;
private Button button1;
private SaveFileDialog saveFileDialog2;
private int currentImageHash = 0;
public ImageStatisticsWindow()

{
InitializeComponent();
}

internal class ColorImageStatisticsDescription
{
private ImageStatistics statRGB;
private ImageStatisticsHSL statHSL;
private ImageStatisticsYCbCr statYCbCr;

[Category("0: General")]
public int PixelsCount
{
get { return statRGB.PixelsCount; }
}

[Category("0: General")]
public int PixelsWithoutBlack
{
get { return statRGB.PixelsCountWithoutBlack; }
}

[Category("1: Red ")]
public int RedMin
{
get { return statRGB.Red.Min; }
}

[Category("1: Red ")]
public int RedMax
{
get { return statRGB.Red.Max; }
}
}

public void GatherStatistics(Bitmap image)
{

if (image != null)
{
if (currentImageHash == image.GetHashCode())
return;
currentImageHash = image.GetHashCode();
}
else
{

propertyGrid.SelectedObject = null;
return;
}

System.Diagnostics.Debug.WriteLine("--- Gathering stastics");

if (image.PixelFormat == PixelFormat.Format24bppRgb)
{

Capture = true;
Cursor = Cursors.WaitCursor;

ColorImageStatisticsDescription statDesc = new ColorImageStatisticsDescription(image);

propertyGrid.SelectedObject = statDesc;
propertyGrid.ExpandAllGridItems();

Cursor = Cursors.Arrow;
Capture = false;
}
else
{
propertyGrid.SelectedObject = null;
}
}

public ColorImageStatisticsDescription(Bitmap image)
{

int width = image.Width;
int height = image.Height;

BitmapData imgData = image.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);

statRGB = new ImageStatistics(imgData);
statHSL = new ImageStatisticsHSL(imgData);
statYCbCr = new ImageStatisticsYCbCr(imgData);

image.UnlockBits(imgData);
}
meenakshi syal 6-Sep-13 7:28am View

Deleted
how to export property grid values to excel using c# window application ? is my question
meenakshi syal 6-Sep-13 7:27am View

Deleted
how to export property grid values to excel using c# window application ? is my question
meenakshi syal 7-Dec-12 4:32am View

I have tried the code but its not working and the video is not running
meenakshi syal 7-Dec-12 4:32am View

Deleted
I have tried the code but its not working and the video is not running
meenakshi syal 6-Dec-12 23:45pm View

I require import of multiple text files selected columns in window application not in web forms
meenakshi syal 6-Dec-12 4:08am View

Deleted
see the solution i have written my code there but I want to import multiple txt files in a datagrid view...
meenakshi syal 5-Dec-12 23:38pm View

Deleted
I tried this code but it browse only one txt file at a time ...

below is the code

namespace Import_CSV_file_into_DataGridView
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void btnBrowse_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
DialogResult dlgResult = dlg.ShowDialog();
if (dlgResult == DialogResult.OK)
{
txtPath.Text = dlg.FileName;
}
}

private void btnLoadData_Click(object sender, EventArgs e)
{
string rowValue;
string[] cellValue;

if (System.IO.File.Exists(txtPath.Text))
{

cellValue = rowValue.Split(',');
for (int i = 0; i <= cellValue.Count() - 1; i++)
{
DataGridViewTextBoxColumn column = new DataGridViewTextBoxColumn();
column.Name = cellValue[i];
}