|
Hi,
I am not sure what you mean by table. If its just a visual thing, you might consider
using a Panel, and drawing in it:
- 9 or 11 horizontal lines
- 9 or 11 vertical lines
- your ellipse (redrawn based on a Forms.Timer for animation)
|
|
|
|
|
Now I do this.
private void timer1_Tick(object sender, EventArgs e)
{
X1 += 5;
Y1 += 5;
Invalidate();
SolidBrush myBrush = new SolidBrush(Color.Green);
dataGridView1.Refresh();
Graphics grfx = dataGridView1.CreateGraphics();
grfx.FillEllipse(myBrush, X1, Y1, 15, 15);
}
But I ask is there any other way to do this
|
|
|
|
|
Hi,
some remarks:
1. you should call Dispose() on all objects you create from classes that offer a public
Dispose() method as soon as you dont need the objects any more. It applies to both
myBrush and grfx.
2. you could keep myBrush alive and reuse it over and over.
you should not do that with grfx
3. I would do the painting in a paint handler, not the timer tick (but of course the
x1/y1 update and the Invalidate() belong inside the tick handler). AS a result the
ellipse gets redrawn also every time it got damaged (e.g. when moving another window
over it without having to wait for the next timer tick (dont know what its period is).
BTW The PaintEventArgs offer you a free graphics, so you then dont need CreateGraphics
anymore, and dont have to Dispose() it.
|
|
|
|
|
Hi
Can you send me a sample code how can I do this in paint handler
X and Y is updated in timer tick at 100ms.
|
|
|
|
|
Hi,
create and wire a paint handler for your dataGridView1 or add the relevant lines to an
existing one:
private SolidBrush myBrush = new SolidBrush(Color.Green);
private void dataGridView1_Paint(object sender, PaintEventArgs e) {
Graphics g=e.Graphics;
g.FillEllipse(myBrush, X1, Y1, 15, 15);
}
That should do it.
|
|
|
|
|
I'm so sorry but something wrong.
I try this any times today.
Is there something else in timer tick except to update X and Y value and to Invalidate().Because my dataGridView is repainted only when over it move another window.
Sorry but I'm beginer.
|
|
|
|
|
Hi,
if dataGridView1 is the only thing changed by your timer, then it also is the only
thing that needs to be invalidated, so try dataGridView1.Invalidate() there.
Dont be afraid to try a couple of things, you learn more by having a good balance
between doing some experiments and asking some questions...
|
|
|
|
|
It's my last question.
The effect is the same when in timer tick I make dataGridView1.Refresh();
Byt my dataGridView1 blink every timer tick
|
|
|
|
|
Hi,
that is no surprise, each control that gets redrawn by default starts of with clearing
the background, then painting the foreground.
There is an easy way to make this invisible, it is known as "double buffering" (which
means the drawing is made first in an off-screen buffer, then that one is copied over
the relevant part of the screen). There is Control.DoubleBuffered starting .NET 2.0;
for .NET 1.x you can achieve the same effect using SetStyles on an inherited Control.
Lots of articles on CP use these techniques.
|
|
|
|
|
I have a popup form which comes up on change of combo item, I am not able to see the images on the form every time.Even the operations on the form are also not happening every time.
Can i get some ideas for this?
Thanks in advance,
Sireesha.
|
|
|
|
|
Are you using Visual Studio 2003 or .Net 1.1?
|
|
|
|
|
Keith Flanagan wrote: Are you using Visual Studio 2003 or .Net 1.1
Why "or"?
|
|
|
|
|
You could be using any number of methods for writing code, from notepad - sharpdevelop VS etc. My question was if it is .Net 1.1 or not.
|
|
|
|
|
Hmmmm????
Keith Flanagan wrote: My question was if it is .Net 1.1 or not.
Actually you where asking if he uses "Visual Studio 2003 or .Net 1.1".
He could also use SharpDevelop with .Net1.1!
|
|
|
|
|
Correct but you could just as easily be using just the SDK and the C# compiler with a text editor
|
|
|
|
|
Make sure you have put showdialog for you form popup on the combo box item changed event. if so, do you see any flickring on the form or you don't see any control on your form? if flickring is there, enable double buffering.
|
|
|
|
|
Sirr/Madam,
Is it right to say that the internal and internal protected access modifiers are accessible in the private assembly.
Thanks and Regards
Pankaj
|
|
|
|
|
You are correct that internal means that it is accessible in the pribate assembly. The prodtected access modifier means that it is accessible within its class and by derived classes. Here is an example for Protected from Microsoft help:
using System;
class A
{
protected int x = 123;
}
class B : A
{
static void Main()
{
A a = new A();
B b = new B();
// Error CS1540, because x can only be accessed by
// classes derived from A.
// a.x = 10;
// OK, because this class derives from A.
b.x = 10;
}
}
Hope that helps.
Ben
|
|
|
|
|
I have been trying to change color of tab control. But all i could do is change the color of tab - pages present on the tab control. It looks very awkward that tab pages of different color and the panel on which these pages are present is default color. Please if any one knows how to change the color of the tab control...
~Vikram Verma
|
|
|
|
|
|
Thanks martin... But isnt there any way provided in visual studio.. I guess this is a common problem.
|
|
|
|
|
vikram Verma wrote: I guess this is a common problem.
Yes,
vikram Verma wrote: But isnt there any way provided in visual studio
No, not that I know!
If you search here on the forum, you will find a lot of questions about that!
|
|
|
|
|
I have declared object in C#. And I want to use a method(logon) for that object in the next statement. Is there any way in C# to do like that. If I try to use it shows "Object does not contain definition for this method". I have tried in VB.net. It is working fine.
siva
siva
|
|
|
|
|
MyClass obj = new MyClass();
obj.Method(param);
if this doesn't help then show us the code...
life is study!!!
|
|
|
|
|
object objsession = Glue.newInstance("ClassName")
when this method is executed, it creates an object objsession. But there is a method called logon after the session is created.
objsession.logon(username,password)
This doesnot work. But in VB.net it works. Is there any solution?
|
|
|
|