|
Josh, thank you so much for you ongoing (!) help. I've not worked with SQLParameters before. Do you know of a good article or can you give me another push?
|
|
|
|
|
What is it that you need to know? You can create one like this:
SqlParameter param = new SqlParameter( "@PartID", partIDValue );
and then just pass it into a method like any other variable.
Josh
|
|
|
|
|
Then why does it still hate this?
private void BindData()<br />
{<br />
strPartNumberInputReference = txtSearchPart.Text;<br />
ds = new DataSet();<br />
SqlParameter param = new SqlParameter("@PartID", strPartNumberInputReference); <br />
ds=SqlHelper.ExecuteDataset(this.connectionString, "dbo.GetPartInfo", "@PartID");<br />
Session["ds"]=ds;<br />
dt = ds.Tables[0];<br />
Session["dt"]=dt;<br />
dgParts.DataSource=dt;<br />
dgParts.DataBind();<br />
txtSearchPart.Text = "";<br />
<br />
}
|
|
|
|
|
leckey wrote: Then why does it still hate this?
Because it is mean and it's father used to beat it with a baseball bat.
You aren't passing the 'param' object into the ExecuteDataset method. Creating it is one thing, using it another.
Cheers & beers,
Josh
|
|
|
|
|
Thanks again! A new problem has arisen. I get "Object must implement IConvertible." Trying to research this so I can stop bugging CodeProject...In my stored procedure I have
@PartID varchar
Is this the issue?
|
|
|
|
|
The problem is not in the stored procedure. SPs have no concept of IConvertible, that's a .NET thing. Turn on your debugger and see where the exception is thrown. It is impossible to figure out what the issue is based on just that error message alone.
Josh
|
|
|
|
|
Hi,
I'm trying to create a custom control to draw a graph in a canvas in real-time, similarly to an osciloscope. I have a main control loop that performs some calculations and updates the current point coordinates (x and y, with x corresponding to the time). I used to use Flash, but due to performance issues I decided to try out using C# (waht means I'm new to C#).
I'm already able to draw lines on my control, but I'm not able to update the canvas whenever a new point is calculated. The problem is that I don't know how to trigger the paint event. I've already registered it, but I don't know how to call it after the point is calculated.
I hope I made myself clear...
Thanks in advance,
Ze Augusto
|
|
|
|
|
Call Invalidate() on the control. That will post a request for a repaint, but if you really need an immediate repaint you should call Update() after calling Invalidate(). Note, you can also call Refresh(), which basically calls those two methods for you.
|
|
|
|
|
First, thanks for your help. I did what you suggested, and it did solve the repaint issue. Now I can see the lines been updated.
Now, the problem is that the screen is getting erased before the new point is drawn (as it would be expected from your description), but I need to keep the points already drawn and add the new point to the end of the line, forming a continuous curve. Then, when that line reaches the end (right border) of the canvas, I should send the carrier back to the begining (left border) and continue drawing, with a blank region in front of it, as if there was an eraser in front of the current point.
Thanks again!
|
|
|
|
|
ZeAugusto wrote: as if there was an eraser in front of the current point.
No erasing but the graphics system does not remember what you previously drew, you have to do that and draw everything in the window (or invalid region) during a paint event. Last modified: Wednesday, June 21, 2006 12:58:57 PM --
|
|
|
|
|
Rather than invalidating the control, call yourCustomControl.CreateGraphics() to get a Graphics object which will render onto your control surface. Then perform the painting in a separate method (not the Paint event handler). That new method will draw only the new point(s) and not erase the other ones. You'll probably want to have your Paint event handler call into this new method so that the rendering logic is factored properly.
Josh
|
|
|
|
|
I think a proper way is using double-buffering. You maintain a graphical buffer and you draw to the buffer. Whenever you want to update the screen, copy the buffer to the screen. There are two approaches to the buffer drawing:
1) If you just add (not erase, not change) contents to the screen, grab the graphic object and draw to the buffer on the top of existing contents.
2) If you erase or change any existing contents on the screen, you need to repaint the buffer's background and then redraw it completely.
I've assumed you have fair understanding about how Windows graphics work. If you need more guidance, drop a line.
Best,
Jun
|
|
|
|
|
Thanks for all the replies!
As I didn't know how to add content without refreshing the whole object, I ended up implementing a mixture of your suggestion with Josh's and Led's ones. I used the GraphicsPath class instead of just drawing single line segments, adding the newly calculated points to it, and then redrew the entire path at every Refresh() call (which happens whenever I add a point to the graph, every 40 ms). At the end of the line, I clone this path to a second one, and reset the first. This way, I work with two paths, the most recent one "above" the oldest, and redraw both when a new point is added.
To solve that "erasing" part I mentioned before, I used a little trick. I draw a black rectangle (because the background of the graph region is also black) between the two paths, and resize it so that it is always a few pixels wider than the top path. This way, it looks like there is an eraser in front of the line being drawn. It's quite similar to what I've already done in Flash.
But I have a new question, though. As far as I draw all these objects every 40 miliseconds, I wonder if I might experience some performance issues. The application is intended to support an average of 5 to 10 simutaneous instances of this control, so that might become a problem... Or am I just being paranoid because of my Flash experience?
Thanks,
Ze
|
|
|
|
|
ZeAugusto wrote: I wonder if I might experience some performance issues.
Can't say for sure. Keep your fingers crossed.
ZeAugusto wrote: The application is intended to support an average of 5 to 10 simutaneous instances of this control, so that might become a problem...
It also depends on how large (portion of screen taken) your control is.
Best,
Jun
|
|
|
|
|
|
Hi,
My opacity control causes a really bad BLACK flicker after the opacity is initially decreased via the trackbar control. Any ideas on how to get rid of the black flicker would be greatly appreciated.
PS: I tried calling Invalidate and ReDraw after Opacity is adjusted with no luck.
Some of the code...
//
// trackBar1
// Code located on the fader (opacity) control
this.trackBar1.Location = new System.Drawing.Point(26, 14);
this.trackBar1.Maximum = 100;
this.trackBar1.Minimum = 10;
this.trackBar1.LargeChange = 5;
this.trackBar1.SmallChange = 5;
this.trackBar1.Name = "trackBar1";
this.trackBar1.Size = new System.Drawing.Size(220, 45);
this.trackBar1.TabIndex = 0;
this.trackBar1.TickFrequency = 10;
this.trackBar1.TickStyle = System.Windows.Forms.TickStyle.Both;
this.trackBar1.Value = 100;
this.trackBar1.MouseUp += new
System.Windows.Forms.MouseEventHandler(this.TrackBar1_ValueChanged);
private void TrackBar1_ValueChanged(object sender, System.EventArgs e)
{
if (_OpacityChanged != null)//run event
{
_OpacityChanged(this.trackBar1.Value);
}
}
// Code located on the main form. User clicks button to bring up control
private void faderControl_Click(object sender, EventArgs e)
{
FaderControl myFaderControl = new FaderControl();
myFaderControl._OpacityChanged += new
FaderControl.UpdateOpacity(OnOpacityChanged);
myFaderControl.ShowDialog();
}
private void OnOpacityChanged(double OpacityValue)
{
double newOpacityValue = OpacityValue / 100;
this.Opacity = newOpacityValue;
}
|
|
|
|
|
Are you setting styles for double buffering and all painting in wmpaint?
|
|
|
|
|
Mike, Thanks for your reply!
I am setting all controls that go on the form to this.DoubleBuffering = true.
How do I set all painting to wmpaint? I'm not familiar with this property.
Tom
|
|
|
|
|
SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
|
|
|
|
|
Mike,
Thanks again, I'm using something similar. On all forms and controls I envoke...
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint |
ControlStyles.OptimizedDoubleBuffer, true);
Still Ugly Black Flicker occurs!
Tom
|
|
|
|
|
Cubzfan wrote: On all forms and controls I envoke
No. In your custom control. FaderControl is your own custom control right? That's what is flickering yes?
|
|
|
|
|
Mike,
No, the form the control is changing the Opacity flickers black when the control is initially taken from the default full opaque setting to any decrease setting. The control works fine after that. If you increase or decrease the parent forms opacity with the child control it changes as it should unless the control is once again set all the way to the right (max setting the parent form to full opaqe) and you decrease again the black flicker happens again.
Hope this helps clear things up???
I really appreciate the help!!
|
|
|
|
|
So you are working on a Custom Control, you are changing the opacity of a .NET Form. Yeah I have no idea what might help with that. See Dustin Metzgar's post maybe it will help.
|
|
|
|
|
Which OS are you using? I noticed having flicker problems in Win 2000, but everything was fine in XP.
Logifusion[^]
|
|
|
|
|
Dustin,
Thanx for the reply! I am using XP.
|
|
|
|