473,414 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

how to access menu of MDI form from a child menu in C#

I am trying to develop a small window application in C# as a front end and SQL server as a back end, but I couldn't make visibility false on the menu of MDI form from a child form. for example I want to make visibility of one of the menu that I created on the MDI form from a login form, for the case of the wrong user name and password entry.

here is the code I write on the login form (which has two text boxes one for user name and the other for password and I have attached my MDI form.
thank you.

Expand|Select|Wrap|Line Numbers
  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Microsoft.VisualBasic;
  10. using System.Data.SqlClient;
  11.  
  12. namespace Lesson01.Security
  13. {
  14.     public partial class frmLogin : Form
  15.     {
  16.       Utilities.frmMDI frmMdi = new Lesson01.Utilities.frmMDI();
  17.  
  18.  
  19.         public frmLogin()
  20.         {
  21.             InitializeComponent();
  22.         }
  23.  
  24.         private void frmLogin_Load(object sender, EventArgs e)
  25.         {
  26.  
  27.         }
  28.         private void frmLoging_FormClosed(object sender, FormClosedEventArgs e)
  29.         {
  30.             Modules.modMain.frmLoging = null;
  31.         }
  32.  
  33.         private void cmdOK_Click(object sender, EventArgs e)
  34.         {
  35.             string SQL = "";
  36.             Class.clsConn dbConn = new Class.clsConn();
  37.  
  38.             SQL = "SELECT * FROM tblUser ";
  39.             dbConn.Oreader(SQL);
  40.               if (dbConn.reader != null)
  41.                 {
  42.                     if (dbConn.reader.Read())
  43.                     {
  44.                         if (txtUserName.Text.Trim() != dbConn.reader.GetString(0) && txtPassword.Text.Trim() == dbConn.reader.GetString(1))
  45.                         {
  46.  
  47.                             MessageBox.Show("Please Enter Valid User Name");
  48.                             txtUserName.Text = "";
  49.                             txtUserName.Focus();
  50.                                           frmMdi.mnuHelp.Visible = false;
  51.                      frmMdi.mnuOptions.Visible = false;
  52.                      frmMdi.mnuReport.Visible = false;
  53.                      frmMdi.mnuTask.Visible = false;
  54.  
  55.  
  56.                         }
  57.                    if (txtUserName.Text.Trim() == dbConn.reader.GetString(0) && txtPassword.Text.Trim() != dbConn.reader.GetString(1))
  58.                         {
  59.                                                         MessageBox.Show("Please Enter Valid password");
  60.                             txtPassword.Text = "";
  61.                             txtPassword.Focus();
  62.                                       frmMdi.mnuHelp.Visible = false;   
  63.                      frmMdi.mnuOptions.Visible = false;
  64.                      frmMdi.mnuReport.Visible = false;
  65.                      frmMdi.mnuTask.Visible = false;
  66.  
  67.  
  68.  
  69.                         }
  70.                         if (txtUserName.Text.Trim() == dbConn.reader.GetString(0) && txtPassword.Text.Trim() == dbConn.reader.GetString(1))
  71.                         {
  72.                             Modules.modMain.userName = txtUserName.Text.Trim();
  73.  
  74.  
  75.                         frmMdi.mnuHelp.Visible = true;
  76.                         frmMdi.mnuOptions.Visible = true;
  77.                         frmMdi.mnuReport.Visible = true;
  78.                         frmMdi.mnuTask.Visible = true;
  79.                                                        dbConn.cn.Dispose();
  80.                             this.Close();
  81.  
  82.                         }
  83.                     }
  84.  
  85.                 }
  86.  
  87.              }
  88.  
  89.         private void cmdCancel_Click(object sender, EventArgs e)
  90.         {
  91.  
  92.             this.Close();
  93.         }
  94.  
  95.  
  96.  
  97.     }
  98. }
  99.  
Attached Images
File Type: jpg Mdi.jpg (24.4 KB, 1763 views)
Mar 31 '11 #1
4 4076
I couldn't make visibility false of menu in MDI parent form from a child form in C#.
for example I have a MDI form which has two menus (Maintain and Task) and on the first menu I have a sub menu called "Maintain Item" so I need to make visibility false for the sub menu from a child form eg. from a login form.
any help would be appreciated.
Thank you.
Apr 7 '11 #2
Plater
7,872 Expert 4TB
HAve you tried changing the Enabled property of the menu item?
Apr 11 '11 #3
yes I have checked it and it is true. but I need to make visibility false for the case of the user enters wrong user name and/or password. but if the user enter valid user name and password on the login form the menus which are on the Main MDI form will be displayed (the visibility is true).
Apr 14 '11 #4
Plater
7,872 Expert 4TB
I think menus have an event that is something like "before popup" which fires before the menu is shown.
You could do your logic about verifying if the user is correct and blank out the item then?
Apr 18 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jan Sokol | last post by:
When you open MDI Child form inside of MDI Parent form, menu of the MDI Child form is added to the menu of MDI Parent. Is there a way to keep menu of MDI Child form on this form, not to move it on...
4
by: Sean Connery | last post by:
I know I can merge a child forms menu into the MDI parent's mainmenu, but I would also like to listen for common events fired from the mainmenu that might be of interest to any child forms. Is...
0
by: Bruce Pataki | last post by:
In MFC and MDI application, Main frame window has its own menu but how can I add child menu to the MDI window?
4
by: Chris Lane | last post by:
I have a form declared like this in the html <form id="SearchResults" method="post" runat="server" name="frmMain"></form> I don't see the form anywhere in the codebehind and I am not able to...
0
by: Lasse Edsvik | last post by:
Was wondering if you guys have managed to do a asp-function that prints out a full menu using SOThink menu builder. the example http://www.sothink.com/product/dhtmlmenu/store/aspdb/aspdb.php is...
0
by: ILCSP | last post by:
Hello, I have a VB.Net project where I have created a dynamic menu. This menu has 2 parents (File and Edit) and I need to place 3 child submenus under Edit at runtime. The problem is that I am...
1
by: sukeshchand | last post by:
-------------------------------------------------------------------------------- In vb we use the following code for gettigng the menu names in a form Dim mc As Variant For Each mc In...
13
by: jmartmem | last post by:
Greetings, I am using Dreamweaver CS3 to design an ASP page that contains a Record Insertion Form. Within this form are two list/menu form fields that I would like to "synchronize". In other...
7
by: Darin | last post by:
I have a parent form that has a menu. I then have a child form on the menu. From the child form I need to change the parent form's menu - how can i do that? I tried me.parent.mfavorites, but that...
0
by: nomad | last post by:
Hi, I have the menu below. I was wondering if it was possible to highlight the selected child menu item when the user hovers over it? <span id="MainMenuHolder" onmenuitemclick="OnClick"...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.