Sorting on Datagridview removes values from Image column en removes row.height [modified]
-
Hi all, Wel the title says it all... I have a datagridview with a dataset as Datasource, having a few textcolumns and an imagecolumn. When I click on the columnheader of a textcolumn the sorting happens but all my rows are back at the initial height and all the images are gone from the imagecolumn... strange behaviour,
public partial class Form1 : Form
{
private DataSet Dataset1;
private FileDialog FileDialog1;
private StringCollection rows ;public Form1() { InitializeComponent(); Dataset1 = new DataSet(); Dataset1.ReadXml(@"..\\..\\Current.xml"); dataGridView1.DataSource = Dataset1; dataGridView1.DataMember = "item"; this.FormClosing += new FormClosingEventHandler(FormClosing1); this.Activated += new EventHandler(FrmActive); FileDialog1 = new OpenFileDialog(); // Restore the columns' state StringCollection cols = new StringCollection(); cols = Properties.Settings.Default.DataGridViewFormColumns; for (int i = 0; i < cols.Count; ++i) { string\[\] array = cols\[i\].Split(','); this.dataGridView1.Columns\[i\].DisplayIndex = Int16.Parse(array\[0\]); this.dataGridView1.Columns\[i\].Width = Int16.Parse(array\[1\]); this.dataGridView1.Columns\[i\].Visible = bool.Parse(array\[2\]); } } private void FrmActive(object sender, EventArgs e) { SetPics(); // I do this only once when the form starts ... so remove handler // this.Activated -= new EventHandler(FrmActive); this.dataGridView1.Rows\[0\].Height = 100; // get settings rows = new StringCollection(); rows = Properties.Settings.Default.DataGridViewFormRows; for (int i = 0; i < rows.Count; ++i) { this.dataGridView1.Rows\[i\].Height = Convert.ToInt16(rows\[i\]); } } // here i want to keep the column and rows height , here is NO problem private void FormClosing1(object sender, EventArgs e) { Dataset1.WriteXml(@"..\\..\\Current.xml"); StringCollection stringCollection = new StringCollection(); foreach (DataGridViewColumn column in this.dataGridView1.Columns) { stringColl
-
Hi all, Wel the title says it all... I have a datagridview with a dataset as Datasource, having a few textcolumns and an imagecolumn. When I click on the columnheader of a textcolumn the sorting happens but all my rows are back at the initial height and all the images are gone from the imagecolumn... strange behaviour,
public partial class Form1 : Form
{
private DataSet Dataset1;
private FileDialog FileDialog1;
private StringCollection rows ;public Form1() { InitializeComponent(); Dataset1 = new DataSet(); Dataset1.ReadXml(@"..\\..\\Current.xml"); dataGridView1.DataSource = Dataset1; dataGridView1.DataMember = "item"; this.FormClosing += new FormClosingEventHandler(FormClosing1); this.Activated += new EventHandler(FrmActive); FileDialog1 = new OpenFileDialog(); // Restore the columns' state StringCollection cols = new StringCollection(); cols = Properties.Settings.Default.DataGridViewFormColumns; for (int i = 0; i < cols.Count; ++i) { string\[\] array = cols\[i\].Split(','); this.dataGridView1.Columns\[i\].DisplayIndex = Int16.Parse(array\[0\]); this.dataGridView1.Columns\[i\].Width = Int16.Parse(array\[1\]); this.dataGridView1.Columns\[i\].Visible = bool.Parse(array\[2\]); } } private void FrmActive(object sender, EventArgs e) { SetPics(); // I do this only once when the form starts ... so remove handler // this.Activated -= new EventHandler(FrmActive); this.dataGridView1.Rows\[0\].Height = 100; // get settings rows = new StringCollection(); rows = Properties.Settings.Default.DataGridViewFormRows; for (int i = 0; i < rows.Count; ++i) { this.dataGridView1.Rows\[i\].Height = Convert.ToInt16(rows\[i\]); } } // here i want to keep the column and rows height , here is NO problem private void FormClosing1(object sender, EventArgs e) { Dataset1.WriteXml(@"..\\..\\Current.xml"); StringCollection stringCollection = new StringCollection(); foreach (DataGridViewColumn column in this.dataGridView1.Columns) { stringColl
workround: If I sort from code I have a work round to add the images again after DatagridView.Sort() but if a user sorts by clicking then I need a event like 'AfterSort' or something which doesn't seem to exist ... ...
°°°°°°°°°°°°°°°°°°°°°°° -- Inter Access Belgium --