Click here to Skip to main content
15,913,610 members
Home / Discussions / C#
   

C#

 
AnswerRe: Taborder for Dynamically-Created Controls Pin
I Believe In GOD23-Sep-08 6:33
I Believe In GOD23-Sep-08 6:33 
AnswerRe: Taborder for Dynamically-Created Controls Pin
danielhasdibs23-Sep-08 6:52
danielhasdibs23-Sep-08 6:52 
QuestionChanging Word save directory in C# Pin
Dave Aitch23-Sep-08 4:30
professionalDave Aitch23-Sep-08 4:30 
AnswerRe: Changing Word save directory in C# Pin
selcuks23-Sep-08 4:34
selcuks23-Sep-08 4:34 
GeneralRe: Changing Word save directory in C# Pin
Dave Aitch23-Sep-08 5:03
professionalDave Aitch23-Sep-08 5:03 
QuestionControls parent is null in call back procedure when control is reloaded Pin
Chazzysb23-Sep-08 4:01
Chazzysb23-Sep-08 4:01 
AnswerRe: Controls parent is null in call back procedure when control is reloaded Pin
Wendelius23-Sep-08 8:44
mentorWendelius23-Sep-08 8:44 
QuestionSorting on Datagridview removes values from Image column en removes row.height [modified] Pin
ddecoy23-Sep-08 3:37
ddecoy23-Sep-08 3:37 
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)
                {
                stringCollection.Add(string.Format("{0},{1},{2}",column.DisplayIndex,column.Width,column.Visible));
                }
            Properties.Settings.Default.DataGridViewFormColumns = stringCollection;
            Properties.Settings.Default.Save();

            stringCollection = new StringCollection();
            foreach (DataGridViewRow row in this.dataGridView1.Rows)
                { 
                  stringCollection.Add(Convert.ToString(row.Height));
                }
            Properties.Settings.Default.DataGridViewFormRows = stringCollection;
            Properties.Settings.Default.Save();
        }


        // I load the pics after Form active...
        private void SetPics()
        {
            for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
            {
                string ImagePath = Convert.ToString(dataGridView1.Rows[i].Cells["Picture_Path"].Value);
                System.Drawing.Bitmap Image1 = new System.Drawing.Bitmap(ImagePath);
                dataGridView1.Rows[i].Cells["Picture"].Value = Image1;
            }
        }



All this actualy works great, only when i sort a column , row.heigth and images are gone ??
ps: I tested the datagridview.Sort() method which has the same behaviour ....

Thanks in advance,

Steven

modified on Tuesday, September 23, 2008 9:56 AM

AnswerRe: Sorting on Datagridview removes values from Image column en removes row.height Pin
ddecoy23-Sep-08 5:02
ddecoy23-Sep-08 5:02 
QuestionConverting C++ COM to C# Pin
LeonardLay23-Sep-08 3:32
LeonardLay23-Sep-08 3:32 
AnswerRe: Converting C++ COM to C# Pin
cpkilekofp25-Sep-08 3:00
cpkilekofp25-Sep-08 3:00 
Question64 bit WMI Pin
arkiboys23-Sep-08 3:17
arkiboys23-Sep-08 3:17 
JokeRe: 64 bit WMI Pin
Giorgi Dalakishvili23-Sep-08 3:38
mentorGiorgi Dalakishvili23-Sep-08 3:38 
GeneralRe: 64 bit WMI Pin
arkiboys23-Sep-08 4:06
arkiboys23-Sep-08 4:06 
GeneralRe: 64 bit WMI Pin
Giorgi Dalakishvili23-Sep-08 4:10
mentorGiorgi Dalakishvili23-Sep-08 4:10 
GeneralRe: 64 bit WMI Pin
arkiboys23-Sep-08 4:13
arkiboys23-Sep-08 4:13 
GeneralRe: 64 bit WMI Pin
#realJSOP23-Sep-08 23:28
professional#realJSOP23-Sep-08 23:28 
GeneralRe: 64 bit WMI Pin
cpkilekofp24-Sep-08 7:05
cpkilekofp24-Sep-08 7:05 
GeneralRe: 64 bit WMI Pin
arkiboys24-Sep-08 20:53
arkiboys24-Sep-08 20:53 
GeneralRe: 64 bit WMI Pin
cpkilekofp25-Sep-08 2:55
cpkilekofp25-Sep-08 2:55 
GeneralRe: 64 bit WMI Pin
arkiboys25-Sep-08 3:41
arkiboys25-Sep-08 3:41 
GeneralRe: 64 bit WMI Pin
cpkilekofp25-Sep-08 3:55
cpkilekofp25-Sep-08 3:55 
GeneralRe: 64 bit WMI Pin
arkiboys25-Sep-08 4:07
arkiboys25-Sep-08 4:07 
GeneralRe: 64 bit WMI Pin
cpkilekofp25-Sep-08 5:30
cpkilekofp25-Sep-08 5:30 
GeneralRe: 64 bit WMI Pin
arkiboys25-Sep-08 22:10
arkiboys25-Sep-08 22:10 

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.