Click here to Skip to main content
15,886,634 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi guys ,

This is my first question, excuse me if i have grammatical error
I have a problem with this event , sometimes this event doesn't occur , example i write this line code for a button:
C#
dataGridView1.Rows[min_index].Selected = true;
dataGridView1.FirstDisplayedScrollingRowIndex = min_index;

min_index row be selected but selectionchanged event doesn't work and sometimes that search result has one result this event doesn't occur again

thanks
Posted
Updated 20-Oct-12 11:11am
v2
Comments
Scott Clayton 20-Oct-12 17:51pm    
Could you show us the code in the SelectionChanged event? Perhaps it is being raised but not doing anything noticeable due to some conditional statement. I'm also assuming that "sometimes" means that it does get raised once in a while, just not every time. Is that right?

1 solution

yes , thank you for answer
this event work properly when with mouse chenge selection but when we want jump to special row it doesn't work , sometimes in search result it happens andsometimes itsn't happen

this is my code in selectionchange event

C#
try
            {
                stu_id = Convert.ToInt64(dataGridView1.CurrentRow.Cells[13].Value);
                schoolin_id = Convert.ToInt64(dataGridView1.CurrentRow.Cells[14].Value);
                Class = Convert.ToInt32(dataGridView1.CurrentRow.Cells[15].Value);
                IList<students> s = new List<students>();
                s = D_Students.Search_stu_id(stu_id);
                txt_name.Text = s[0].NAME;
                txt_family.Text = s[0].FAMILY;
                txt_f_name.Text = s[0].FATHER_NAME;
                IList<schooling_sign> sd = new List<schooling_sign>();
                sd = D_Schooling_Sign.Select_Year(schoolin_id);
                txt_schooling.Text = sd[0].YEAR;
                txt_class.Text = class_schooling.number_to_schooling(Class);
                button2.Enabled = true;
            }
            catch (Exception) { }


</schooling_sign></schooling_sign></students></students>


3 first line indicate to previose selected row not current selected row
thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900