|
I apologize for not mentioning this before, but my question regards to WinForms and not ASP.NET.
Thank you.
|
|
|
|
|
Is there a way to adjust the height of the rows in a listview? It seems that the function GetItemRect gets called when painting the control but it's not virtual so I can't override it. Will I have to do all the painting myself?
Thanks,
Rob Tomson
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
Hi Folks,
I just was experimenting with customizing the MenuItem class to suit my needs. I have introduced an accessor method which handles an additional string variable in my inherited class called PJMenuItem.
PJMenuItem pjmi = new PJMenuItem();
pjmi.ExtraInfo = "c:\\temp\\";
pjmi.Text = "HelloWorld";
cm.MenuItems.Add(pjmi.Text,new System.EventHandler(LaunchAction));
Now the problem becomes that each time the menuitem gets invoked via the LaunchAction event handler an exception message gets thrown. Stating that the specified cast is invalid. The event handler is defined as
private void LaunchAction(object sender, System.EventArgs e)
{
try
{
PJMenuItem pjmi = (PJMenuItem) sender;
MessageBox.Show(pjmi.ExtraInfo.ToString());
}
catch(System.Exception ee)
{
MessageBox.Show(ee.ToString());
}
}
Can anyone please tell me how I can overcome this exception error ???
thanks
|
|
|
|
|
You're using the wrong overload of the Add method. Passing a string as the frst parameter causes a new MenuItem to be created for you, with the supplied text as the caption and the specified handler. You need to specify the handler in your PJMenuItem constructor (and pass it to the base class constructor) then used the version of the Add method that takes a reference to the menuitem.
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
g'day Rob
Would it be possible for you to give me another example of your explanation as I am unable to follow through. The point I am having difficulty is with the part where you said i need to specify the event handler in the constructor and then passing it to the base class constructor.
I am refering to the following article on msdn about base class constructors:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vclrfbasepg.asp
But I cant seem to draw a correlation between the msdn article and your explanation.
I would really appreciate it if you could give me another example.
thanks.
|
|
|
|
|
G'day again Rob,
I read your post again and again inconjunction with Uncle gate's article, I finally understood it. Thanks for helping me out.
|
|
|
|
|
How can I capture output from cmd? From executing some command in cmd like "tracert" or "ping"...
Thankss....
|
|
|
|
|
What do you use to execute the command?
---
b { font-weight: normal; }
|
|
|
|
|
Have a look at System.Diagnostics.Process.StartInfo.RedirectStandardOutput .
Matt Gerrans
|
|
|
|
|
thx a lot it's working very well
|
|
|
|
|
okay, here it is. i have this
as my opengl window, on load, and this image i need to draw fullscreen. basically the code looks like this:
this.ClientSize = new System.Drawing.Size(640, 480);,
GL.glVertex3f(0f,0f,0f);
GL.glVertex3f(640f,0f,0f);
GL.glVertex3f(640f,480f,0f);
GL.glVertex3f(0f,480f,0f);, and
GL.glOrtho(0,640,0,480,0,1);. as previously stated, i want the image to be drawn in the exact amount of pixels that it came with. in case pointers arent enough and a whole source fix is needed, the source for tyhe entire program can be found here. thanks for your time
|
|
|
|
|
//Label x axis. Trying to label graph axes on a WinForm
Font graphFont = new Font("Arial",8);
Brush graphBrush = new SolidBrush(Color.BlueViolet);
float x = 0.0f;
String xString = x.ToString();
for(float gx = xIndent; gx <= graphRect.Width; gx += gx)
{
g.DrawString(xString, graphFont, graphBrush, this.ClientRectangle.Left + xIndent, yOrigin + 4);
}
//THANKS FOR ANY HELP.....
|
|
|
|
|
see reply below. No need to repost...
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
Rob,
EXACTLY what my App needed.Didn't even know there was such a thing as
"current culture". Many thanks.....
|
|
|
|
|
If you ever intend to write applications that might be used outside your country, you should read up on the CultureInfo[^]and System.Globalization [^] Name space. Most of the string formatting and comparison functions in .NET have overloads that expect culture specific parameters, and it is generally recommended that you use these to get predicatable results in all languages.
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
how do i make my file system watcher watch my dir and all it subdir to i have to create a file system watcher for each sub dir too.
Thanks
chad
|
|
|
|
|
if i understand what you want correctly
what about IncludeSubdirectories Property
indicating whether subdirectories within the specified path should be monitored
fileSystemWatcher.IncludeSubdirectories=true
MCAD
|
|
|
|
|
thank you so much i forgot about that property
chad
|
|
|
|
|
Hi!
Im using an arraylist bound to a datagrid to show some info. I also let the user delete rows from the datagrid using a contextmenu. IE rightclick on the row, choose "delete item", and the row disappears.
Everything works fine except when I delete the last row, then when I choose another row I get a "Index out of range exception".
this is my deletemethod:
private void DeleteItem(object sender, System.EventArgs e)
{
//get the index of the selected Item, same index in the ArrayList
int index = commentGrid.CurrentCell.RowNumber;
try
{
comments.Comments.RemoveAt(index);
if (comments.Comments.Count < 1)
{
menuItemExport.Enabled = false;
toolBar.Buttons[2].Enabled = false;
}
dataChanged = true;
commentGrid.DataSource = null;
commentGrid.Refresh();
commentGrid.DataSource = comments.Comments;
commentGrid.Refresh();
}
catch(ArgumentOutOfRangeException)
{
return;
}
}
I heard this was some kind of bug in .NET, but I dont know how to work around the problem! Any help is much appreciated.
thanks!
/Rickard
|
|
|
|
|
Actually I am looking for a text control that responds to the "Enter" key event i.e. when the enter key is pressed the event handler for it is called.
Actually what i want do is that when enter key is pressed the focous shift to the next control.
Will be very thankful for you help
Your!
shahzad zafar siddiqui
|
|
|
|
|
You can achive what you want by handle keypress event
Catch enter key
Set The Focus to the next control
Try some thing like this
<code>
private void Text_KeyPress
(object sender,System.Windows.Forms.KeyPressEventArgs e)
{
if(e.KeyChar==(char)13)
{
this.GetNextControl(textBox1,true).Focus();
e.Handled=true;
}
}
</code>
MCAD
|
|
|
|
|
hi
i want to do something like u.. when the user press "enter" after keying in some information in the textbox, it'll open something for display, for my case it's opening a tab page..
i tried the method above but it cant work.. i donno why..
my button is button3, textbox is textBox4 and it will open a tab page called tabPage6..
btw what does (char)13 mean in >> if(e.KeyChar==(char)13) ?
why is there a 13 and must i use it in my program too?
thanks
|
|
|
|
|
13 is the numeric value of the character sent by the enter key.
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
nidhelp wrote:
i want to do something like u.. when the user press "enter" after keying in some information in the textbox, it'll open something for display, for my case it's opening a tab page..
i tried the method above but it cant work.. i donno why..
my button is button3, textbox is textBox4 and it will open a tab page called tabPage6
you can modify the code above to do what you want
the code did not work because -i think- the tabcontrol not the next control to textbox i mean if textbox tabindex=7 the tabcontrol should be 8
you can do somthing like that
private void Text_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if(e.KeyChar==(char)13)
{
tabControl1.Focus();
tabControl1.SelectedTab=tabPage2;
e.Handled=true;
}
}
nidhelp wrote:
btw what does (char)13 mean in >> if(e.KeyChar==(char)13) ?
why is there a 13 and must i use it in my program too?
as rob said this the value of enterkey as this numric value and KeyChar type is Char so we need to cast it
in other word convert numric value to char
one of the method to do that is
(char)13 which wil do the conversion
if you want to know the value of other key
look at
Keys Enumeration[^]
MCAD
|
|
|
|
|
i tried modifying again but it still cant work.. i want to ask..
private void Text_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) << do i write Text_KeyPress too? or should i replace Text with something else?
{
if(e.KeyChar==(char)13)
{ //this.GetNextControl(textBox1,true).Focus(); >> do i remove the //?
tabControl1.Focus(); tabControl1.SelectedTab=tabPage2; e.Handled=true;
}
}
as for tabControl1, textBox1 and tabPage2 in the above codes, do i write the relevant names of my tabcontrol, textbox and tabpage of what i want to link to/from?
thanks!
|
|
|
|