Solved

Controlling Custom Controls on Windows Forms -- HELP :)

Posted on 2004-03-28
3
780 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now