Solved

Controlling Custom Controls on Windows Forms -- HELP :)

Posted on 2004-03-28
3
782 Views
Last Modified: 2007-12-19
I am writing a program that has tab controls, on these tab controls I have a grid and on the double click event from the grid I then replace the grid control with a custom form control that allows for editing and such. That part is working great, the problem i am having is switching back :)

because the control.cs is different class from the grid I need to switch back after editing and saving or through a button.

here's an idea of what i am doing.

from the grid that exist in panelMain
            private void gridMain_DoubleClick(object sender, EventArgs e) {
                  GridArea hitTest = gridMain.HitTest();
                  if (hitTest == Janus.Windows.GridEX.GridArea.Cell | hitTest == GridArea.CardCaption | hitTest == GridArea.CardColumnHeader | hitTest == GridArea.PreviewRow | hitTest == GridArea.RowHeader) {
                        // update the dataview
                        utils.DataRowVw = ((System.Data.DataRowView)(gridMain.GetRow().DataRow));
                        // load the form
                        FormSites fs = new FormSites();
                        fs.id = utils.DataRowVw["SiteID"].ToString();
                        this.panelMain.Controls.Add(fs);
                        fs.Dock = DockStyle.Fill;
                        this.panelMain.Controls.Remove(gridMain);
                  }
            }
            public void loadList() {
                  this.panelMain.Controls.Add(gridMain);
                  gridMain.Dock = DockStyle.Fill;
                  this.panelMain.Controls.Remove(); // this is also a problem here
            }
now this successfully works and loads the control and removes the grid.

from the control i am trying to call the loadlist() method, it see's it but doesn't execute no errors or nothing
            private void btnLists_Click(object sender, System.EventArgs e) {
                  vwSites vw = new vwSites();
                  vw.loadList();
            }

If anyone can help i would sure apreciate it, i'm on a time crunch :)

Thanks

0
Comment
Question by:joshcrosby
  • 2
3 Comments
 
LVL 9

Expert Comment

by:msdixon
ID: 10704661
why not just show/hide the controls? this would allow you to refresh the grid from the database after the user updates the data.
0
 
LVL 1

Author Comment

by:joshcrosby
ID: 10714055
how would i do that across classes?
0
 
LVL 9

Accepted Solution

by:
msdixon earned 500 total points
ID: 10714277
you can expose a method or function in your class. it might be easier to make a helper class to do so, or you can put that functionality in your form.

i don't understand why in your loadList method you're adding a control, then perfoming an action on that control, then removing all controls.  maybe that's your problem.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question