|
This is the correct way to do it, as described here[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
That doesn't work in .NET 2.0+, since you can't prefix a class name with a "part" of the namespace like that.
Bastard Programmer from Hell
|
|
|
|
|
OP is using .NET 4.0.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Shouldn't work in 4.0 either, but I'm too lazy to give it a try right now
Bastard Programmer from Hell
|
|
|
|
|
Eddy Vluggen wrote: Shouldn't work in 4.0 either
I've used it in 3.0 and it worked fine. Did you read the linked article I referred to?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
That tells us that you have probably used VB to implement the example, as C# doesn't allow a prefix of the classname with a partial namespace;
Namespace Mine.Test
Public Class SomeClass
Public Property P As Guid
End Class
End Namespace
--
Imports ScratchVb.Mine
Module Module1
Sub Main()
Dim X As Object = New Test.SomeClass()
End Sub
End Module
using System;
namespace Mine.Test
{
class SomeClass
{
public Guid P { get; set; }
}
}
--
using Mine;
namespace Scratch
{
class Program
{
static void Main(string[] args)
{
Object X = new Test.SomeClass();
Object X = new Mine.Test.SomeClass();
}
}
}
Yes, read the article some time ago. Did you try it?
Bastard Programmer from Hell
|
|
|
|
|
Eddy Vluggen wrote: That tells us that you have probably used VB to implement the example, as C# doesn't allow a prefix of the classname with a partial namespace;
Wrong on both counts.
Eddy Vluggen wrote: Yes, read the article some time ago. Did you try it?
Yes I tried it, using C# as i)I never use or have used VB/VB.NET and ii)the title of the article is How to automate Microsoft Excel from Microsoft Visual C#.NET!
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Richard MacCutchan wrote: Yes I tried it, using C#
Never mind
Bastard Programmer from Hell
|
|
|
|
|
Eddy Vluggen wrote: Never mind
I don't mind, it's you that kept banging on about it, like a
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
when you do
using some1.some2.some3;
then the C# compiler will add "some1.some2.some3" to the list of known prefixes, which it uses to locate a type.
Therefore,
using System.Windows.Forms;
...
Form f=new Form();
Forms.Form f2=f;
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
i think you should use "Add reference",
right click on form->Add reference,
there you will get all the namespace which are available.
|
|
|
|
|
I've added the MS Excel 14.0 Object Library reference (COM Tab), Richard the link that you have recommended is one that I have already followed but I was still getting the error.
|
|
|
|
|
pmcm wrote: Richard the link that you have recommended is one that I have already followed but I was still getting the error.
Can you show your code and the exact text of the error message?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I fixed this issue by doing:
using Microsoft.Office.Interop;
using Excel = Microsoft.Office.Interop.Excel;
using Word = Microsoft.Office.Interop.Word;
|
|
|
|
|
That's what I suggested yesterday.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi.
I write a code for create a polygan in c#
Now i want moving it on the form but i cant.
I want know how i can move a polygan on the form.
My code for create a polygan is:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace graphic_aghaye_bagheri
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public class polygan
{
public int x1;
public int y1;
public int x2;
public int y2;
public int x3;
public int y3;
public int x4;
public int y4;
public int x5;
public int y5;
public polygan(int x11, int y11,int x22,int y22,int x33,int y33,int x44,int y44,int x55,int y55)
{
x1 = x11;
y1 = y11;
x2 = x22;
y2 = y22;
x3 = x33;
y3 = y33;
x4 = x44;
y4 = y44;
x5 = x55;
y5 = y55;
}
}
private Graphics x;
private Pen myPen = new Pen(Color.Tomato,5);
int r = 30;
int currentvert = 5;
private polygan polygan1 = new polygan(200,200,300,200,350,250,300,300,200,300);
private void button1_Click(object sender, EventArgs e)
{
Point[] myPoints = { new Point(200, 200), new Point(300, 200), new Point(350, 250), new Point(300, 300), new Point(200, 300) };
Graphics myG = this.CreateGraphics();
Pen myPen =new Pen(Color.Tomato, 4f);
x.DrawPolygon(myPen, myPoints);
timer1.Start();
}
private void Form1_Load(object sender, EventArgs e)
{
x = this.CreateGraphics();
}
private void timer1_Tick(object sender, EventArgs e)
{
polygan1.x1 = polygan1.x1 + r;
polygan1.y1 = polygan1.y1 + r;
polygan1.x2 = polygan1.x2 + r;
polygan1.y2 = polygan1.y2 + r;
polygan1.x3 = polygan1.x3 + r;
polygan1.y3 = polygan1.y3 + r;
polygan1.x4 = polygan1.x4 + r;
polygan1.y4 = polygan1.y4 + r;
polygan1.x5 = polygan1.x5 + r;
polygan1.y5 = polygan1.y5 + r;
}
}
}
Tanks a lot.
|
|
|
|
|
Just updating the points in your timer won't actually redraw your polygon. You actually need to trigger a paint message to redraw the polygon (the crudest method being to refresh the form). You really need to move the paint functionality into the form Paint event handler so you can just get the Graphics object there rather than creating your own (which you haven't disposed).
The other big problem is that you create your polygon and then you don't use it to draw with. I would fix that if I were you.
|
|
|
|
|
You may want to read this article[^], it explains the principles you need.
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
Copy this code after creating a new form (without copying form references).
You need to copy namespaces as well.
Run it and see what issues you get - you can post them here and someone may help you.
|
|
|
|
|
Abhinav S wrote: Copy this code Are you referring to the code in the link posted by Luc ? ... or ... missing link ?
thanks, Bill
"The first principle is that you must not fool yourself, and you are the easiest person to fool." Richard Feynman
|
|
|
|
|
I'm referring to the code that the OP has posted.
|
|
|
|
|
This is quite close to a self-submission to the Hall of Shame. You don't appear to have understood how to do custom painting at all (hint: check out the Paint event), you never read the values out of your 'polygan' (sic) class, you allocate and never dispose of extra graphic objects, you use meaningless names ...
You really need to go away and understand the WinForms graphics model properly. I could give an entire solution but it wouldn't help you actually learn the principles you are so clearly lacking.
|
|
|
|
|
Could u tell me how to get name and count of tables in a MS Access database?
I tried by MSysObjects but i have an error.
Error says that to use administrator account.
But i have used just an administrator account one. Could u tell me any other ways for that matter.
|
|
|
|
|
PiebaldConsultant gave you and Answer yesterday[^]. If you want more help you will need to be more specific:
1) Did you try his suggestion it should work- if not what went wrong
2) How are you accessing MSysObjects (supply code)?
Point 2 is most important as there are several scenarios:
A: You are accessing the table directly in which case you need to be an admin on the database
B: You are accessing via an application
If this is using windows authentication to the database: The account the app is running under needs to be an admin on the database. For a winforms app, it would be running under your account. Web apps are more complicated and you'll need to work out which account is being used.
If this is using an "SQL account" (i.e. you have supplied a username and password)to the database: The account specified needs to be an admin on the database
|
|
|
|
|
There is "SYS" in MSysObjects, no wonder you need a special account when going that route.
Stick with OleDbConnection.GetSchema() as Piebald told you.
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|