Solved

Controlling Custom Controls on Windows Forms -- HELP :)

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

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…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

615 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