Solved

Controlling Custom Controls on Windows Forms -- HELP :)

Posted on 2004-03-28
3
789 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: 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

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.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

730 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