|
hi everyone,
I am working in a C# 2.0 Windows Aplication and it had a menu strip. I made a function to hide some of its MenuItems under certain circumstances. the Function was some thing like this
public static void Hide_MenuItems(MenuStrip menustrip)
{
try{
menustrip.Items["productsMenuStipItem"].Visible = false;
menustrip.Items["productreportsMenuStipItem"].Visible = false;
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
Now that code is giving a Null reference exception on productreportsMenuStipItem which is an item that come under the MenuItem like this Products--->Product Reports.
So far I'm not able to understand why this is happening coz when I write this
productreportsMenuStipItem.Visible = false;
in the form that has that menuStrip it working perfectly alright but when I try to do that in this function it gives out a nullReferenceException. It seems as if the only Menuitems tranfered are the ones that are at level zero. like that productsMenuStripItem.
Can u plz give me a clue so that I can hide the menuStipItems with the help of this function? or atleast explain why this is happening?
thanks in advance
Rocky
|
|
|
|
|
I am guessing this has to do with nested menu items. It seems like you are hiding the parent item so the children items aren't there. I am not sure why you are doing it this way. You can access the object directly.
this:
productreportsMenuStipItem.Visible = false;
is not the same as this:
menustrip.Items["productreportsMenuStipItem"].Visible = false;
One you are marking the menu item itself as not visible. Then other you are using the Menustrip to access the menuitem. I would suggest always accessing the menustripitem directly and I think you won't have any problems.
Hope that helps.
Ben
|
|
|
|
|
Hello,
I have a long treeView, how can I scroll to the top of the control, without selecting anything?
Please help.
|
|
|
|
|
|
well as far as my knowledge goes, I think its impossible really. Think some other way instead of this idea. As far as I see it Crystal reports doesnt allow you to access its inner details via programming.
Rocky
|
|
|
|
|
Hi Everyone,
here i am with really a mystic question.
the scenario is:
-=-=-=-=-=-=-=-=-=-
I have a repeater and a checkbox.The checkbox is databounded in the repeater.There are 4 rows in the database.when the page is loaded,the 4 checkboxes are created dynamically w.r.t rows in table.When the check box is checked,the corresponding id's of the checkboxex are to be captured in an event.
And My query is:
-=-=-=-=-=-=-=-=-=-
how can we get the ID's of the corresponding checkbox when the checkbox is checked?
thanks
tirumal.
-- modified at 6:37 Tuesday 24th April, 2007
|
|
|
|
|
how to create a error log files?
how to handle the user exceptions while run the web application?
|
|
|
|
|
you handle the user exceptions using the traditional try/catch/finally(optional) block.
Keshav Kamat
India
|
|
|
|
|
i actually did not get you properly.
do you mean to say, you want to make sure that the user does not enter wrongly or something.
in that case you want something called validation.
You need to check out key press event in that case.
Keshav Kamat
India
|
|
|
|
|
The error log files can be created in the global.asax page.
the below code might help you.
string errorpath = Server.MapPath(ConfigurationManager.AppSettings.Get("ErrorPath"));
Exception objErr = Server.GetLastError().GetBaseException();
str = str + "Time : " + (DateTime.Now.TimeOfDay).ToString() + "*";
str = str + "Message : " + objErr.Message + "*";
tirumal
|
|
|
|
|
Hi,
I am trying to add to a context menu a textbox suimila to what you have in Access.
is it possible, if so how?
Regards
Alban
|
|
|
|
|
I think its pretty simple just make a new MenuStrip And in the designer view go to the properties of that textbox and add the menu to the contextMenuStrip Property of that text box and thats it.
hope it helps
Rocky
|
|
|
|
|
hi alban,
For .net 1.1
Add a context menu from the toolbox to the form, add sub menu's as required by you
Then go to the textbox property,then set ContextMenu property to context menu which you have created.
For .net 2.0
Add a contextmenustrip from the toolbar to the form, add sub menu's as required by you
Then go to the textbox property, then set ContextMenuStrip property to context menu strip which you have created
|
|
|
|
|
I may have miss explaiend myself.
What i am trying to have is within the context menu having a textbox that would come up as per the menu structure show bellow.
ContextMenu
SubMenuA Textbox
SubMenuB
Thanks
|
|
|
|
|
You can make a borderless form and then use that as your context menu.
Just make the form apear when you right click the textbox.
To exchange information to this context menu, you can add a reference to the base form in the contstructor
of the contectmenuform
Programming code is like magic, just use the right code (magic words) to make happen what you want..
|
|
|
|
|
Hi,
I want to know the difference between array and arrylist.
thanx
|
|
|
|
|
Both are collections.
But you have to provide the size of an array before you use it, may not be compulsory at the time of declaration.
But with an array list, you dont have to.
You use the add property to add on any number of items you want to.
eg ArrayList1.Add("Something"); if it is a string arraylist.
You might want to refer the msdn library for more.
Keshav Kamat
India
|
|
|
|
|
|
An array is a fixed size list or matrix with elements of a specific type.
Examples:
int[] primes = { 2, 3, 5, 7, 11, 13, 17, 19 };<br />
string[] chessPieces = new string[7,1];
An ArrayList is a dynamic list of objects. As any data type can be handled as the type Object, you can store anything in the list.
Example:
ArrayList items = new ArrayList();<br />
items.Add(42);<br />
items.Add("Answer");<br />
int answer = (int)items[0];<br />
string info = (string)items[1];
---
single minded; short sighted; long gone;
|
|
|
|
|
arraylist provide u functions to add,remove,insert etc.. items in the list..
while array didn't
|
|
|
|
|
Hello Everyone,
I want to open, play, pause and stop Mpeg files in WindowsMediaPlayer using Windows application.
I have added the wmp.dll(windowMediaPlayer dll) to the references. By using the WindowsMediaPlayer class, I am able to open the player
( this is how it is -
WindowsMediaPlayerClass wmPlayer = new WindowsMediaPlayerClass();
wmPlayer.openPlayer(@"C:\monkeydog.wmv"); )
, but I am not able to implement the Pause, Stop and fullscreen functionalities.
I tried these functionalities with - wmPlayer.controls.stop()and wmPlayer.controls.pause(), but this is not working fine.
Once the MediaPlayer starts, it nethier stops nor pauses.
Can someone help me out with this. Its quiet urgent.
Thanks..
Kraj
|
|
|
|
|
In order to control media playback using the Play, Pause, or Stop methods of the MediaElement control, the LoadedBehavior property must be set to Manual.
Check out here[^]
Keshav Kamat
India
|
|
|
|
|
How can I set this in C# windows application?
Can I set this through button properties.
Any alternative solutions?
|
|
|
|
|
kraj99 wrote: WindowsMediaPlayerClass wmPlayer = new WindowsMediaPlayerClass();
You should just be able to add the control to your form in the designer.
kraj99 wrote: wmPlayer.controls.stop()and wmPlayer.controls.pause(), but this is not working fine.
I've used the WMP control a lot, and those functions work fine for me. You probably need to post some code to try to work out what you're doing wrong.
kraj99 wrote: Its quiet urgent.
Aren't they all ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Below is the sample code. One more thing I want to mention here is that I am using a third party GUI software, so I wont be able to add WMP control on to the Window Form. I just need to control the WMPlayer by the code.
The below mentioned code is able to open the player. But the stop and close functionalities are not working.
public partial class Form1 : Form
{
private WindowsMediaPlayerClass wmPlayer = new WindowsMediaPlayerClass();
//private WindowsMediaPlayer wmPlayer = new WindowsMediaPlayer();
public Form1()
{
InitializeComponent();
}
private void Play_Click(object sender, EventArgs e)
{
wmPlayer.openPlayer(@"C:\SampleVideo.wmv");
}
private void Stop_Click(object sender, EventArgs e)
{
wmPlayer.close();
//wmPlayer.controls.stop();
}
}
thanks
|
|
|
|