Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Controlling Custom Controls on Windows Forms -- HELP :)

Posted on 2004-03-28
3
Medium Priority
?
808 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Integration Management Part 2
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

971 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