Hide some menu items as per user rights












-3















I'm making an application which requires users with different permissions/privileges to login and use the application.For example, if the user is "admin", all menu items in the menu bar are shown and enabled. If the user is say "user1", some of the menu items are to be hidden. The same for "user2", "user3", "user4" and so on.



How do it in windows desktop application c# ? Any Clue ,demo or video ?










share|improve this question

























  • You can check user level from login and store that as a global variable and when loading forms check load controllers according to the level

    – Gihan Saranga Siriwardhana
    Nov 16 '18 at 9:27











  • As you say, can u send me any example link ? @GihanSarangaSiriwardhana

    – saeed ahmed
    Nov 16 '18 at 9:45


















-3















I'm making an application which requires users with different permissions/privileges to login and use the application.For example, if the user is "admin", all menu items in the menu bar are shown and enabled. If the user is say "user1", some of the menu items are to be hidden. The same for "user2", "user3", "user4" and so on.



How do it in windows desktop application c# ? Any Clue ,demo or video ?










share|improve this question

























  • You can check user level from login and store that as a global variable and when loading forms check load controllers according to the level

    – Gihan Saranga Siriwardhana
    Nov 16 '18 at 9:27











  • As you say, can u send me any example link ? @GihanSarangaSiriwardhana

    – saeed ahmed
    Nov 16 '18 at 9:45
















-3












-3








-3








I'm making an application which requires users with different permissions/privileges to login and use the application.For example, if the user is "admin", all menu items in the menu bar are shown and enabled. If the user is say "user1", some of the menu items are to be hidden. The same for "user2", "user3", "user4" and so on.



How do it in windows desktop application c# ? Any Clue ,demo or video ?










share|improve this question
















I'm making an application which requires users with different permissions/privileges to login and use the application.For example, if the user is "admin", all menu items in the menu bar are shown and enabled. If the user is say "user1", some of the menu items are to be hidden. The same for "user2", "user3", "user4" and so on.



How do it in windows desktop application c# ? Any Clue ,demo or video ?







c# visual-studio-2015






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 10:36







saeed ahmed

















asked Nov 16 '18 at 9:24









saeed ahmedsaeed ahmed

54210




54210













  • You can check user level from login and store that as a global variable and when loading forms check load controllers according to the level

    – Gihan Saranga Siriwardhana
    Nov 16 '18 at 9:27











  • As you say, can u send me any example link ? @GihanSarangaSiriwardhana

    – saeed ahmed
    Nov 16 '18 at 9:45





















  • You can check user level from login and store that as a global variable and when loading forms check load controllers according to the level

    – Gihan Saranga Siriwardhana
    Nov 16 '18 at 9:27











  • As you say, can u send me any example link ? @GihanSarangaSiriwardhana

    – saeed ahmed
    Nov 16 '18 at 9:45



















You can check user level from login and store that as a global variable and when loading forms check load controllers according to the level

– Gihan Saranga Siriwardhana
Nov 16 '18 at 9:27





You can check user level from login and store that as a global variable and when loading forms check load controllers according to the level

– Gihan Saranga Siriwardhana
Nov 16 '18 at 9:27













As you say, can u send me any example link ? @GihanSarangaSiriwardhana

– saeed ahmed
Nov 16 '18 at 9:45







As you say, can u send me any example link ? @GihanSarangaSiriwardhana

– saeed ahmed
Nov 16 '18 at 9:45














1 Answer
1






active

oldest

votes


















0














You can use dynamic menu creation.



You should have userType and menu items for that particular user type in table.



On For initiate fetch get menu items from your database with respective of user type and bind it MenuStrip with below code.



  foreach (DataRow dr in YourMenuListTable.Rows)

{

MnuStripItem = new ToolStripMenuItem(dr["MAINMNU"].ToString());

//SubMenu(MnuStripItem, dr["MENUPARVAL"].ToString());

MnuStrip.Items.Add(MnuStripItem);

}





share|improve this answer
























  • i am making window application when the user click menu -> sub menu then the form is open. As u say, its generate dynamic menu but how the related form clicked with generated dynamic menu ? @Nakul

    – saeed ahmed
    Nov 16 '18 at 9:41













  • The same wat you can generate onClick event MnuStripItem.Click += new EventHandler(MnuStripItem_click); For this you have to store one more data in MenuTable, that is form name, and then pass form name click

    – Nakul
    Nov 16 '18 at 9:56












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53334862%2fhide-some-menu-items-as-per-user-rights%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You can use dynamic menu creation.



You should have userType and menu items for that particular user type in table.



On For initiate fetch get menu items from your database with respective of user type and bind it MenuStrip with below code.



  foreach (DataRow dr in YourMenuListTable.Rows)

{

MnuStripItem = new ToolStripMenuItem(dr["MAINMNU"].ToString());

//SubMenu(MnuStripItem, dr["MENUPARVAL"].ToString());

MnuStrip.Items.Add(MnuStripItem);

}





share|improve this answer
























  • i am making window application when the user click menu -> sub menu then the form is open. As u say, its generate dynamic menu but how the related form clicked with generated dynamic menu ? @Nakul

    – saeed ahmed
    Nov 16 '18 at 9:41













  • The same wat you can generate onClick event MnuStripItem.Click += new EventHandler(MnuStripItem_click); For this you have to store one more data in MenuTable, that is form name, and then pass form name click

    – Nakul
    Nov 16 '18 at 9:56
















0














You can use dynamic menu creation.



You should have userType and menu items for that particular user type in table.



On For initiate fetch get menu items from your database with respective of user type and bind it MenuStrip with below code.



  foreach (DataRow dr in YourMenuListTable.Rows)

{

MnuStripItem = new ToolStripMenuItem(dr["MAINMNU"].ToString());

//SubMenu(MnuStripItem, dr["MENUPARVAL"].ToString());

MnuStrip.Items.Add(MnuStripItem);

}





share|improve this answer
























  • i am making window application when the user click menu -> sub menu then the form is open. As u say, its generate dynamic menu but how the related form clicked with generated dynamic menu ? @Nakul

    – saeed ahmed
    Nov 16 '18 at 9:41













  • The same wat you can generate onClick event MnuStripItem.Click += new EventHandler(MnuStripItem_click); For this you have to store one more data in MenuTable, that is form name, and then pass form name click

    – Nakul
    Nov 16 '18 at 9:56














0












0








0







You can use dynamic menu creation.



You should have userType and menu items for that particular user type in table.



On For initiate fetch get menu items from your database with respective of user type and bind it MenuStrip with below code.



  foreach (DataRow dr in YourMenuListTable.Rows)

{

MnuStripItem = new ToolStripMenuItem(dr["MAINMNU"].ToString());

//SubMenu(MnuStripItem, dr["MENUPARVAL"].ToString());

MnuStrip.Items.Add(MnuStripItem);

}





share|improve this answer













You can use dynamic menu creation.



You should have userType and menu items for that particular user type in table.



On For initiate fetch get menu items from your database with respective of user type and bind it MenuStrip with below code.



  foreach (DataRow dr in YourMenuListTable.Rows)

{

MnuStripItem = new ToolStripMenuItem(dr["MAINMNU"].ToString());

//SubMenu(MnuStripItem, dr["MENUPARVAL"].ToString());

MnuStrip.Items.Add(MnuStripItem);

}






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 16 '18 at 9:31









NakulNakul

1069




1069













  • i am making window application when the user click menu -> sub menu then the form is open. As u say, its generate dynamic menu but how the related form clicked with generated dynamic menu ? @Nakul

    – saeed ahmed
    Nov 16 '18 at 9:41













  • The same wat you can generate onClick event MnuStripItem.Click += new EventHandler(MnuStripItem_click); For this you have to store one more data in MenuTable, that is form name, and then pass form name click

    – Nakul
    Nov 16 '18 at 9:56



















  • i am making window application when the user click menu -> sub menu then the form is open. As u say, its generate dynamic menu but how the related form clicked with generated dynamic menu ? @Nakul

    – saeed ahmed
    Nov 16 '18 at 9:41













  • The same wat you can generate onClick event MnuStripItem.Click += new EventHandler(MnuStripItem_click); For this you have to store one more data in MenuTable, that is form name, and then pass form name click

    – Nakul
    Nov 16 '18 at 9:56

















i am making window application when the user click menu -> sub menu then the form is open. As u say, its generate dynamic menu but how the related form clicked with generated dynamic menu ? @Nakul

– saeed ahmed
Nov 16 '18 at 9:41







i am making window application when the user click menu -> sub menu then the form is open. As u say, its generate dynamic menu but how the related form clicked with generated dynamic menu ? @Nakul

– saeed ahmed
Nov 16 '18 at 9:41















The same wat you can generate onClick event MnuStripItem.Click += new EventHandler(MnuStripItem_click); For this you have to store one more data in MenuTable, that is form name, and then pass form name click

– Nakul
Nov 16 '18 at 9:56





The same wat you can generate onClick event MnuStripItem.Click += new EventHandler(MnuStripItem_click); For this you have to store one more data in MenuTable, that is form name, and then pass form name click

– Nakul
Nov 16 '18 at 9:56




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53334862%2fhide-some-menu-items-as-per-user-rights%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Error while running script in elastic search , gateway timeout

Adding quotations to stringified JSON object values