|
V.V.Thakur wrote: asp.net
ASP.NET Forum
This is possible to do but unless you have an explicit problem with some code then at least attempt the solution yourself.
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
Hi everyone.
I'm currently working on a larger system that will incorporate several tools including shell extensions.
The contextmenu works fine for when I rightclick single files. All menuitems show, and InvokeCommand is called to do the work assosiated with the menuitem clicked.
But if I select several files, the contextmenu shows, the submenuitems shows and are selectable, but
nothing happends. I got a debugger in InvokeCommand() so I know it isn't called.
Seems to me that there's some kind of pointer / reference mismatch so that explorer isn't firing my
InvokeCommand method.
If anyone has some experience in contextmenu shell extensions I'd appreciate some feed back.
I'll gladly post some code too if it helps.
-Larantz-
|
|
|
|
|
Solved it.
I'll post the solution incase anyone else runs into the same problem.
My extension is made up with dynamic contextmenus that vary in size and content according to the
filetype etc. So I had identifier baseIDs like i.e: baseIDTxt 0, baseIDDoc 100, baseIDRtf 200;
These baseIDs are then used when creating/populating the menus so it's easier to locate the correct
commands when InvokeCommand is called. I'd just switch on the baseids:
case baseIDTxt + 0: //menuitem index 0
//do something to txt file
break;
case baseIDTxt + 1: //menuitem index 1
//do something else to txt file
break;
The problem for me was that if I used a baseID larger then 100 for some of my menus, and the InvokeCommand for that specific contextmenu wouldn't show.
So try and keep them below 100 and you should be fine.
I now have a dynamic contextmenu with dynamic number of sumbmenuitems that varies for 4 filecases.
I used four bases i.e: baseX = 0, baseY = 25, baseZ = 75 and baseLast = 100;
-Larantz-
|
|
|
|
|
hi
iam begginer in c# can anyone help me to know how to accept double values using textbox .
tahnk you in advance
Regards
praveen
|
|
|
|
|
u can try
double db = Double.Parse(textbox1.text);
rahul
|
|
|
|
|
tankyou verymuch for the help it worked
|
|
|
|
|
Hello,
One way is to do it like this (dNumber defined earlier, and in this case textbox is named txtBox):
double dNumber;<br />
<br />
try <br />
{<br />
dNumber = double.Parse(txtBox.Text);<br />
}<br />
catch(FormatException)<br />
{<br />
MessageBox.Show("You typed an invalid value\n\r" +<br />
"Please try again");<br />
}
This diplays an errorbox in case user puts in wrong kind of an input.
-PP
-- modified at 7:29 Wednesday 24th May, 2006
|
|
|
|
|
Howdy,
I'm having some problems having information delivered between a custom user component and the main form.
In the component I have a combobox to where I want to get information from the main form. I tried using the following expression:
<br />
string[] sectionRange = ((Proha)TopLevelControl).giveSections();
ProHa is the Class name. This works, but it says "Object reference not set to an instance of an object" for 3 times whenever I try to view the component in the main form's Design view or run the program.
If the above should be instantiated somehow, how can it be done?
Big thanks to anyone who can help.
|
|
|
|
|
I think, if you create your control for the first time, you must also send a reference of the main form to your component.
e.g.
public class MainForm
{
MyComponent myComp = new MyComponent(this);
}
public class MyComponent
{
private MainForm mainForm = null;
public MyComponent(MainForm mainForm)
{
this.mainForm = mainForm;
}
}
|
|
|
|
|
Thanks, that worked, but now the design view has some problems since I had to modify the constructor in my component and now it doesn't seem to match with something else declared in MyComponent.Designer.cs file. I'll try separating the process from the constructor..
|
|
|
|
|
Good day everyone,
Pls help if you're interested in
I'm doing a handwriting program.
I've got a static method to remove points of line. In this method there are 2 ArrayList. I'd like to remove whatever points they are matched each other. But I've got a problem:Index is out of range...
Anyone know how fix this or other way to compare 2 objects?
Thanks so much
private static void RemovePoint()
{
for (int i = 0; i < pointErase.Count; i ++)
{
for (int j = 0; j < pointArray.Count; j ++)
{
bool isMatch = Object.Equals(pointArray[i], pointErase[j]);
if (isMatch)
{
pointArray.RemoveAt(i);
pointErase.RemoveAt(j);
}
}
}
}
eric
|
|
|
|
|
bool isMatch = Object.Equals(pointArray[i], pointErase[j]);
this line is the wrong way round according to your loops, it should be
bool isMatch = Object.Equals(pointArray[j], pointErase[i]);
As are your lines that actually do the RemoveAt
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
-- modified at 7:12 Wednesday 24th May, 2006
|
|
|
|
|
Yup. You got your indexers mixed up.
V V
bool isMatch = Object.Equals(pointArray[i], pointErase[j]);
if (isMatch)
{
pointArray.RemoveAt(i); <-
pointErase.RemoveAt(j); <-
}
Just switch i for j and j for i and you should be good to go.
-Larantz-
|
|
|
|
|
If you use .NET 2.0 and switch to a List<T> , you can do all this in one line with List<T>::RemoveAll(...)
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
.NET 1.x allowed you to clear an ArrayList with .Clear and where did he say he wanted to remove all from the list?
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
RemoveAll does NOT clear the list. It removes all elements that match a certain predicate (delegate function). In this case, he would pass a predicate to the RemoveAll function that compares all elements against all elements in the other list.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks everyone,
I got it. the capacity of pointArray may be greater than pointErase. So I just delete the erased points only.
eric
|
|
|
|
|
By the way, I still got a problem, I can't write the leftover points to a file.
It keeps writing all points in pointArray and pointErase ArrayList even though I removed erased points before hand.
Pls help if you have time
Thanks
using System;
using System.Drawing;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
namespace Part_2_A2_ST2
{
public class Form1 : System.Windows.Forms.Form
{
private StreamReader sr;
private StreamWriter sw;
private Pen pen;
private Point pt1, pt2;
private bool isMouseDown;
private bool isMouseUp;
private Bitmap tempImage;
private Point pt;
private Graphics g;
private SolidBrush bgBrush;
private static ArrayList pointArray;
private static ArrayList pointErase;
private bool line = false;
private bool eraser = false;
private Point point;
private Graphics tempG;
private static Point ptCount;
private static Point ptErase;
private static string xDraw, yDraw;
private static string xErase, yErase;
private static string drawPoint, erasePoint;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem menuItem7;
private System.Windows.Forms.MenuItem menuItem8;
private System.Windows.Forms.MenuItem menuItem9;
private System.Windows.Forms.ToolBar toolBar1;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.ToolBarButton tbNew;
private System.Windows.Forms.ToolBarButton tbOpen;
private System.Windows.Forms.ToolBarButton tbSave;
private System.Windows.Forms.ToolBarButton toolBarButton1;
private System.Windows.Forms.ToolBarButton tbPointer;
private System.Windows.Forms.ToolBarButton Rectangle;
private System.Windows.Forms.ToolBarButton tbEllipse;
private System.Windows.Forms.ToolBarButton tbLine;
private System.Windows.Forms.ToolBarButton tbPolygon;
private System.Windows.Forms.ToolBarButton toolBarButton2;
private System.Windows.Forms.ToolBarButton tbEraser;
private System.Windows.Forms.ToolBarButton toolBarButton3;
private System.ComponentModel.IContainer components;
public Form1()
{
pointArray = new ArrayList();
pointErase = new ArrayList();
point = new Point(0, 0);
InitializeComponent();
pen = new Pen(Color.Black, 2);
pt1 = new Point(50, 50);
pt2 = new Point(200, 200);
isMouseDown = false;
isMouseUp = false;
tempImage = new Bitmap( SystemInformation.PrimaryMonitorMaximizedWindowSize.Width,
SystemInformation.PrimaryMonitorMaximizedWindowSize.Height);
tempG = Graphics.FromImage(tempImage);
tempG.Clear(this.BackColor);
if (!File.Exists("DataPoints.txt"))
File.Create("DataPoints.txt");
pt = new Point(0,0);
g = this.CreateGraphics();
bgBrush = new SolidBrush(this.BackColor);
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
if (!isMouseDown)
{
using (sr = new StreamReader("DataPoints.txt"))
{
string str = sr.ReadLine();
if (str == null)
return;
string [] strs = str.Split(' ');
if (strs.Length != 2)
return;
Point pt1 = new Point(int.Parse(strs[0]),int.Parse(strs[1]));
Graphics g = e.Graphics;
while ((str = sr.ReadLine()) != null)
{
strs = str.Split(' ');
if (strs.Length != 2)
break;
Point pt2 = new Point(int.Parse(strs[0]),int.Parse(strs[1]));
g.DrawEllipse(Pens.Blue, pt2.X-2, pt2.Y-2, 4, 4);
g.DrawLine(Pens.Black, pt1, pt2);
pt1 = pt2;
}
}
}
}
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (line)
{
isMouseDown = true;
pt1 = new Point(e.X, e.Y);
point = pt1;
sw = new StreamWriter("DataPoints.txt");
}
}
private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (line)
{
if (isMouseDown)
{
pt2 = new Point(e.X, e.Y);
Graphics g = this.CreateGraphics();
g.DrawLine(pen, point, pt2);
tempG.DrawLine(pen, point, pt2);
point = pt2;
xDraw = (e.X).ToString();
yDraw = (e.Y).ToString();
drawPoint = xDraw + " " + yDraw;
AddPointDraw(drawPoint);
}
}
if (eraser)
{
if (isMouseDown)
{
line = false;
g.FillRectangle(bgBrush,e.X-10,e.Y-10,20,20);
g.DrawRectangle(Pens.Red,e.X-10,e.Y-10,20,20);
g.DrawRectangle(new Pen(this.BackColor),pt.X-10, pt.Y-10, 20, 20);
pt.X = e.X;
pt.Y = e.Y;
xErase = (e.X).ToString();
yErase = (e.Y).ToString();
erasePoint = xErase + " " + yErase;
AddPointErase(erasePoint);
}
}
}
private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
eraser = false;
isMouseUp = true;
g.FillRectangle(bgBrush, e.X-10, e.Y-10, 30, 30);
if (line)
{
isMouseDown = false;
this.BackgroundImage = (Bitmap) tempImage.Clone();
sw.Close();
this.Refresh();
}
}
private void Form1_Resize(object sender,System.EventArgs e)
{
this.BackgroundImage = (Bitmap) tempImage.Clone();
}
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
if ( e.Button == tbPolygon)
line = true;
else if (e.Button == tbEraser)
{
eraser = true;
isMouseDown = false;
}
else if (e.Button == tbSave)
Save();
}
public void AddPointDraw(String drawPoint)
{
pointArray.Add(drawPoint);
}
public void AddPointErase(String erasePoint)
{
pointErase.Add(erasePoint);
}
private static void RemovePoint()
{
for (int i = 0; i < pointErase.Count; i ++)
{
for (int j = 0; j < pointArray.Count; j ++)
{
bool isMatch = Object.Equals(pointArray[j], pointErase[i]);
if (isMatch)
{
pointArray.RemoveAt(j);
pointErase.RemoveAt(i);
}
}
}
}
private void Save()
{
RemovePoint();
sw.WriteLine("pointArray...........");
foreach (object s in pointArray)
{
sw.WriteLine(s);
}
sw.WriteLine("pointErase................");
foreach (object s in pointErase)
{
sw.WriteLine(s);
}
sw.WriteLine("Stop--------------------------");
sw.Close();
}
}
}
eric
|
|
|
|
|
hi all,
first: i have 2 forms. first is a login form and the other is my main form.
how can i show thelogineduser and logintime on second form ? (how do i get logintime)
second: is possible to subtract two dates and get the number of days between them ? (exp: 10.08.2010 - 09.09.2006 = ?) or do i have to calculate some extra code ?
thanks in advance,
bye.
|
|
|
|
|
1) Not enough information to answer your question!
2) Subtracting two DateTime instances gives a TimeSpan instance. A TimeSpan instance has a property named TotalDays
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
you can send the logintime to second
form by
form2 frm2 = new form2(logintime);
frm2.show();
you need to modify the costructor of form2 to accept the parameter.
to subtract one date from another you have to store the result in
timespan type of variable
DateTime date1=Convert.ToDateTime("20-12-1978");
DateTime date2=Convert.ToDateTime("20-12-1979");
TimeSpan date3= date2.Subtract(date1);
int days = date3.Days;
rahul
|
|
|
|
|
I searched in MSDN but not found. Please help me how to gets WINDOWS directory like "%Systemroot%" in Windows for Programming!!
Thank you for your support!
|
|
|
|
|
Environment.GetEnvironmentVariable("SYSTEMROOT") points to the Windows directory
Environment.GetFolderPath(SpecialFolder.System) includes the "system32" directory
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
my project have three form, one mdi form and two form children, from one button on form children (form1), how i can call event menuitem_click to call form children (form2). Note, i design menu on mdi form to call form children by menuitem. Help me
Thanks
|
|
|
|
|
//in any event of form2
Form1 f1 = new Form1();<br />
f1.MenuItem_Click(sender,e);
|
|
|
|