|
i am creating a simple timeline using trackbar. In a window form, i have a ruler which located above the trackbar. ruler at form : 0___10___20___30 trackbar control: 0___10___20___30 How could make my trackbar's tick exactly identical with the ruler scale? please help. |
| Nise1990 Thursday, August 20, 2009 5:00 PM |
anyone please?
|
| Nise1990 Thursday, August 20, 2009 11:34 PM |
You can't make this work. TrackBar has a weird problem in that it cannot tell you the first and last tick mark position. The .NET designers omitted it completely. Omitting the ruler is the only workaround I can think of.
Hans Passant. |
| nobugz Friday, August 21, 2009 1:46 AM |
You can't make this work. TrackBar has a weird problem in that it cannot tell you the first and last tick mark position. The .NET designers omitted it completely. Omitting the ruler is the only workaround I can think of.
Hans Passant.
Thanks. generally i'm designing a timeline which i use trackbar control as timeline. So do you have better suggestion for me to accomplish the stuff? |
| Nise1990 Friday, August 21, 2009 3:25 AM |
It is not a very sophisticated control. How about you use a PictureBox with an image of a pretty pointer. You'll just need to add mouse event handlers to move it around.
Hans Passant. |
| nobugz Friday, August 21, 2009 3:50 AM |
It is not a very sophisticated control. How about you use a PictureBox with an image of a pretty pointer. You'll just need to add mouse event handlers to move it around.
Hans Passant.
could i have the example on how to integrate it with case mentioned above? Thanks. |
| Nise1990 Friday, August 21, 2009 4:12 AM |
You'd have a much better shot at getting this right than I would. If the proposed solution isn't clear then ask a question.
Hans Passant. |
| nobugz Friday, August 21, 2009 4:19 AM |
Hi Nise,
I can understand what nobugz said. And here I have write a sample according to his suggestion. Hope you can get help from the sample.
First I create a user control named MyTrackTick, I put 2 picturebox on it, one is above, and another below it. The above picturebox can be filled with a track image. The below one can be filled with an image like a point, just like a hand in the clock, so I give its name picHand. Please look at the following code.
public partial class MyTrackTick : UserControl
{
private Timer timer = new Timer();
public MyTrackTick()
{
InitializeComponent();
timer.Interval = 500;
timer.Tick += new EventHandler(timer_Tick);
timer.Enabled = true;
}
void timer_Tick(object sender, EventArgs e)
{
int position = picHand.Location.X;
picHand.Location = new Point(position + 1, picHand.Location.Y);
}
}
The timer.Tick event will reset picHand’s position. So you can set the picHand move once every 0.5 minute.
If you have any problem about it, please feel free to tell me.
Sincerely,
Kira Qian
Please mark the replies as answers if they help and unmark if they don't. |
| Kira Qian Monday, August 24, 2009 6:17 AM |
Hi Nise,
I can understand what nobugz said. And here I have write a sample according to his suggestion. Hope you can get help from the sample.
First I create a user control named MyTrackTick, I put 2 picturebox on it, one is above, and another below it. The above picturebox can be filled with a track image. The below one can be filled with an image like a point, just like a hand in the clock, so I give its name picHand . Please look at the following code.
public partial class MyTrackTick : UserControl
{
private Timer timer = new Timer ();
public MyTrackTick()
{
InitializeComponent();
timer.Interval = 500;
timer.Tick += new EventHandler (timer_Tick);
timer.Enabled = true ;
}
void timer_Tick(object sender, EventArgs e)
{
int position = picHand.Location.X;
picHand.Location = new Point (position + 1, picHand.Location.Y);
}
}
The timer.Tick event will reset picHand’s position. So you can set the picHand move once every 0.5 minute.
If you have any problem about it, please feel free to tell me.
Sincerely,
Kira Qian
Please mark the replies as answers if they help and unmark if they don't.
i tried your sample... before that.. thanks for your time for replying. I tried your code.. but i'm confused in this senstence "The above picturebox can be filled with a track image. The below one can be filled with an image like a point" So do i need to put anything inside the pictureBox? i run the code.. i do not see anything from it..., just a control in Form1, do i miss something? |
| Nise1990 Tuesday, August 25, 2009 4:18 PM |
Hi Nise, If you don't set any image for the picturebox, its color is the same as the form's default background color. picHand is a very small picture, which only show an arrow point to the above time track. So you need to draw 2 picture. One is time track, another is an arrow. After you set the picture you can see it moving once every 0.5 second. Sincerely, Kira Qian
Please mark the replies as answers if they help and unmark if they don't. |
| Kira Qian Thursday, August 27, 2009 7:51 AM |
Hi Nise, If you don't set any image for the picturebox, its color is the same as the form's default background color. picHand is a very small picture, which only show an arrow point to the above time track. So you need to draw 2 picture. One is time track, another is an arrow. After you set the picture you can see it moving once every 0.5 second. Sincerely, Kira Qian
Please mark the replies as answers if they help and unmark if they don't.
Hi Kira Qian, I have some questions... why you create the control using User Control instead of Windows Form ? And i try to use mouse handler... how to make the poiter could be drag forward and backward? private void picHand_MouseMove(object sender, MouseEventArgs e) { int position = picHand.Location.X; ///picHand.Location = new Point(position, picHand.Location.Y); } And how to add text on the picture box (i.e. mark text / labelling on the slider) on run time? Please guide . thanks |
| Nise1990 Monday, September 21, 2009 2:54 PM |
Hi Nise, If you don't set any image for the picturebox, its color is the same as the form's default background color. picHand is a very small picture, which only show an arrow point to the above time track. So you need to draw 2 picture. One is time track, another is an arrow. After you set the picture you can see it moving once every 0.5 second. Sincerely, Kira Qian
Please mark the replies as answers if they help and unmark if they don't.
Hi Kira Qian, I have some questions... why you create the control using User Control instead of Windows Form ? And i try to use mouse handler... how to make the poiter could be drag forward and backward? private void picHand_MouseMove(object sender, MouseEventArgs e) { int position = picHand.Location.X; ///picHand.Location = new Point(position, picHand.Location.Y); } And how to add text on the picture box (i.e. mark text / labelling on the slider) on run time? Please guide . thanks
Please guide. |
| Nise1990 Tuesday, September 22, 2009 11:22 AM |
Hello, I think you can put some labels on the picturebox to show the text on image. As for user control, it allow you to encapsulate all the methods and properties into it. Just make it convenience to use. Sincerely, Kira Qian
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! |
| Kira Qian Wednesday, September 23, 2009 6:11 AM |
Hello, I think you can put some labels on the picturebox to show the text on image. As for user control, it allow you to encapsulate all the methods and properties into it. Just make it convenience to use. Sincerely, Kira Qian
Please remember to mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework!
could you mind to teach me how to add text /labelling on the picture box at run time? Thanks |
| Nise1990 Wednesday, September 23, 2009 2:57 PM |