help me plssssssssssssss
-
Hello i have wasted lot of time. :( 1I want to put a command button in the datagrid in one of the column. I got a piece of code from this site and i have added to my project. it is working fine except i am having a major issue. when i click on the button, i am poping a form. if i click again, the form gets popped up twice, if i click again, 3 times the form gets popped up. is it due to the events get added up every time when i click on the button. my code is like this buttonColStyle = new DataGridButtonColumn(1) buttonColStyle.HeaderText = "Browse"; buttonColStyle.MappingName = ObjDataColumn.ColumnName; buttonColStyle.CellButtonClicked += new DataGridCellButtonClickEventHandler(HandleCellButtonClick); GridTableStyle.GridColumnStyles.Add(buttonColStyle); this.DGDetails.MouseDown += new MouseEventHandler(buttonColStyle.HandleMouseDown); this.DGDetails.MouseUp += new MouseEventHandler(buttonColStyle.HandleMouseUp); wilson
-
Hello i have wasted lot of time. :( 1I want to put a command button in the datagrid in one of the column. I got a piece of code from this site and i have added to my project. it is working fine except i am having a major issue. when i click on the button, i am poping a form. if i click again, the form gets popped up twice, if i click again, 3 times the form gets popped up. is it due to the events get added up every time when i click on the button. my code is like this buttonColStyle = new DataGridButtonColumn(1) buttonColStyle.HeaderText = "Browse"; buttonColStyle.MappingName = ObjDataColumn.ColumnName; buttonColStyle.CellButtonClicked += new DataGridCellButtonClickEventHandler(HandleCellButtonClick); GridTableStyle.GridColumnStyles.Add(buttonColStyle); this.DGDetails.MouseDown += new MouseEventHandler(buttonColStyle.HandleMouseDown); this.DGDetails.MouseUp += new MouseEventHandler(buttonColStyle.HandleMouseUp); wilson
dear wilson you have to check the instance of the popped-up form every time you click the button. If form's instance already exist then dont make use of new keyword just use the form's "show" method. Use this method to check instance of the form (may be this could be useful) //***********Start********** private Form isFormAlreadyLoaded(Form ToBeLoadedForm) { foreach (Form LoadedForm in this.MdiChildren) { if ((LoadedForm.Name == ToBeLoadedForm.Name) && ((LoadedForm.Text.Trim ()) == ToBeLoadedForm.Text.Trim())) { return LoadedForm; } else { return ToBeLoadedForm; } } return ToBeLoadedForm; } //***********End********** regards Sheel Gohe