Click here to Skip to main content
15,881,769 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionClick Once Deployment & logging Pin
Mr Brown Shoes25-Apr-06 14:41
Mr Brown Shoes25-Apr-06 14:41 
AnswerRe: Click Once Deployment & logging Pin
JimRoss2-May-06 11:38
JimRoss2-May-06 11:38 
GeneralRe: Click Once Deployment & logging Pin
Tailslide5-Nov-09 6:11
Tailslide5-Nov-09 6:11 
QuestionDataGridView.remove how do i call this , help ? Pin
Steve Ryan25-Apr-06 12:01
Steve Ryan25-Apr-06 12:01 
AnswerRe: DataGridView.remove how do i call this , help ? Pin
Mr Brown Shoes25-Apr-06 14:53
Mr Brown Shoes25-Apr-06 14:53 
AnswerRe: DataGridView.remove how do i call this , help ? Pin
Graham Nimbley25-Apr-06 15:10
Graham Nimbley25-Apr-06 15:10 
GeneralRe: DataGridView.remove how do i call this , help ? Pin
Steve Ryan26-Apr-06 14:57
Steve Ryan26-Apr-06 14:57 
GeneralRe: DataGridView.removeat failed, any one help ? Pin
Steve Ryan26-Apr-06 17:48
Steve Ryan26-Apr-06 17:48 
I tested this on a MS example for songs in list box "data grid"

well it told me that i couldnt delete the row

i then tried with a for loop in csharp and was told it could remove an uncommitted row

couldnt find anything on MS on line to help me

any suggestions.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
public partial class Form1 : Form
{

private void SetUpDataGridView()
{
this.Controls.Add(dataGridView1);
dataGridView1.ColumnCount = 5;
DataGridViewCellStyle style =
dataGridView1.ColumnHeadersDefaultCellStyle;
style.BackColor = Color.Navy;
style.ForeColor = Color.White;
style.Font = new Font(dataGridView1.Font, FontStyle.Bold);

dataGridView1.EditMode = DataGridViewEditMode.EditOnEnter;
dataGridView1.Name = "dataGridView1";

dataGridView1.AutoSizeRowsMode =
DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
dataGridView1.ColumnHeadersBorderStyle =
DataGridViewHeaderBorderStyle.Raised;
dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.Single;
dataGridView1.GridColor = SystemColors.ActiveBorder;
dataGridView1.RowHeadersVisible = false;

dataGridView1.Columns[0].Name = "Release Date";
dataGridView1.Columns[1].Name = "Track";
dataGridView1.Columns[1].DefaultCellStyle.Alignment =
DataGridViewContentAlignment.MiddleCenter;
dataGridView1.Columns[2].Name = "Title";
dataGridView1.Columns[3].Name = "Artist";
dataGridView1.Columns[4].Name = "Album";

// Make the font italic for row four.
dataGridView1.Columns[4].DefaultCellStyle.Font = new Font(DataGridView.DefaultFont, FontStyle.Italic);

dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.MultiSelect = false;

dataGridView1.BackgroundColor = Color.Honeydew;

// dataGridView1.Dock = DockStyle.Fill;

// dataGridView1.CellFormatting += new DataGridViewCellFormattingEventHandler(dataGridView1_CellFormatting);
// dataGridView1.CellParsing += new DataGridViewCellParsingEventHandler(dataGridView1_CellParsing);
this.addNewRowButton.Click += new EventHandler(addNewRowButton_Click);
this.deleteRowButton.Click += new EventHandler(deleteRowButton_Click);
this.ledgerStyleButton.Click += new EventHandler(ledgerStyleButton_Click);
//dataGridView1.CellValidating += new DataGridViewCellValidatingEventHandler(dataGridView1_CellValidating);

}

private void PopulateDataGridView()
{

// Create the string array for each row of data.
string[] row0 = { "11/22/1968", "29", "Revolution 9", "Beatles", "The Beatles [White Album]" };
string[] row1 = { "4/4/1960", "6", "Fools Rush In", "Frank Sinatra", "Nice 'N' Easy" };
string[] row2 = { "11/11/1971", "1", "One of These Days", "Pink Floyd", "Meddle" };
string[] row3 = { "4/4/1988", "7", "Where Is My Mind?", "Pixies", "Surfer Rosa" };
string[] row4 = { "5/1981", "9", "Can't Find My Mind", "Cramps", "Psychedelic Jungle" };
string[] row5 = { "6/10/2003", "13", "Scatterbrain. (As Dead As Leaves.)", "Radiohead", "Hail to the Thief" };
string[] row6 = { "6/30/1992", "3", "Dress", "P J Harvey", "Dry" };
string[] row7 = { "6/30/2006", "5", "Expert Rules", "S J Ryan", "Cambridge" };


// Add a row for each string array.
{
DataGridViewRowCollection rows = this.dataGridView1.Rows;
rows.Add(row0);
rows.Add(row1);
rows.Add(row2);
rows.Add(row3);
rows.Add(row4);
rows.Add(row5);
rows.Add(row6);
rows.Add(row7);

}

// Change the order the columns are displayed.
{
DataGridViewColumnCollection columns = this.dataGridView1.Columns;
columns[0].DisplayIndex = 3;
columns[1].DisplayIndex = 4;
columns[2].DisplayIndex = 0;
columns[3].DisplayIndex = 1;
columns[4].DisplayIndex = 2;
}
}


public Form1()
{
InitializeComponent();
}

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{

}
private void ledgerStyleButton_Click(object sender, System.EventArgs e)
{
// Create a new cell style.
DataGridViewCellStyle style = new DataGridViewCellStyle();
{
style.BackColor = Color.Beige;
style.ForeColor = Color.Brown;
style.Font = new Font("Verdana", 8);
}

// Apply the style as the default cell style.
dataGridView1.AlternatingRowsDefaultCellStyle = style;
ledgerStyleButton.Enabled = false;
}


private void addNewRowButton_Click(object sender, EventArgs e)
{
this.PopulateDataGridView();

}

private void deleteRowButton_Click(object sender, EventArgs e)
{
MessageBox.Show("click");
int index = this.dataGridView1.Rows.Count - 1;
bool r;

MessageBox.Show(index.ToString());
for (int i = index; i > 0; i--)
{

this.dataGridView1.Rows.RemoveAt(i);
MessageBox.Show(i.ToString());
// index = this.dataGridView1ows.Count;
}
}

private void ledgerStyleButton_Click_1(object sender, EventArgs e)
{

}

private void Form1_Load(object sender, EventArgs e)
{
this.SetUpDataGridView();
this.PopulateDataGridView();
}
}
}
QuestionMSI Setup always brings back original files... Pin
siliconesoul25-Apr-06 4:04
siliconesoul25-Apr-06 4:04 
QuestionFor minimizing and maximizing Pin
Robert Rohde25-Apr-06 2:49
Robert Rohde25-Apr-06 2:49 
AnswerRe: For minimizing and maximizing Pin
_alank25-Apr-06 3:04
_alank25-Apr-06 3:04 
GeneralRe: For minimizing and maximizing Pin
Robert Rohde25-Apr-06 3:18
Robert Rohde25-Apr-06 3:18 
AnswerRe: For minimizing and maximizing Pin
Graham Nimbley25-Apr-06 13:30
Graham Nimbley25-Apr-06 13:30 
GeneralRe: For minimizing and maximizing Pin
Robert Rohde25-Apr-06 18:02
Robert Rohde25-Apr-06 18:02 
GeneralRe: For minimizing and maximizing Pin
Graham Nimbley26-Apr-06 6:39
Graham Nimbley26-Apr-06 6:39 
QuestionConnection to DB by VC# 2005 Pin
sottos25-Apr-06 1:14
sottos25-Apr-06 1:14 
AnswerRe: Connection to DB by VC# 2005 Pin
Dave Kreskowiak25-Apr-06 10:19
mveDave Kreskowiak25-Apr-06 10:19 
Questionprocess file handles Pin
Arkett25-Apr-06 0:53
Arkett25-Apr-06 0:53 
AnswerRe: process file handles Pin
Dave Kreskowiak25-Apr-06 10:14
mveDave Kreskowiak25-Apr-06 10:14 
GeneralRe: process file handles Pin
Arkett26-Apr-06 2:59
Arkett26-Apr-06 2:59 
GeneralRe: process file handles Pin
Dave Kreskowiak26-Apr-06 6:33
mveDave Kreskowiak26-Apr-06 6:33 
AnswerRe: process file handles Pin
Arkett27-Apr-06 6:15
Arkett27-Apr-06 6:15 
QuestionReleasing Pocket PC Memory with XML data Pin
hollymax24-Apr-06 14:34
hollymax24-Apr-06 14:34 
Questionusing nmake? Pin
ALQallaf24-Apr-06 11:22
ALQallaf24-Apr-06 11:22 
AnswerRe: using nmake? Pin
ALQallaf25-Apr-06 5:49
ALQallaf25-Apr-06 5:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.