|
Thanks alot buddy really help full.....
|
|
|
|
|
Hi,
I use the following code for drawing line on a panel, but after few seconds the line disappear.
Can someone help with this?
Graphics formGraphics = panel1.CreateGraphics();
formGraphics.DrawLine((Pens.Red, p1, p2);
Thanks in advance.
Lune
|
|
|
|
|
Hi,
that indicates you didn't paint it in the right way.
there are several steps to correctly draw something so it becomes visible on the screen:
1.
decide upon what object you want to draw; it normally is a Control (e.g. a Panel) or a
Form itself. I prefer to add a Panel to a Form, then draw on the Panel.
2.
create some variables (Rectangle, struct, class, whatever) that hold the parameters of
your drawing. For a rectangle that could be top and left coordinate, and width+height,
or just a Rectangle. etc.
3.
create a Paint handler (either add your own paint handler to the Paint event, or
override the OnPaint method) for that Panel, and do all your drawing in there,
using the Graphics class and your variables.
4.
when you want to change things, modify the variables and call Panel.Invalidate() or
one of its overloads (for selective invalidation).
5.
If you want to animate things, perform the move (step 4) inside the Tick handler
of a Windows.Forms.Timer
BTW: if you need to create some objects (Fonts, Pens, Brushes, ...) either keep them
alive in class members (hence create them only once); or create them inside the Paint
handler and don't forget to call Dispose() on them.
|
|
|
|
|
And you have the nerve to suggest that I am verbose!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Fortunately I do have a small collection of standard replies available, this is the one I give for all paint problems unless more specific symptoms ask for a more personalized answer.
|
|
|
|
|
Thanks,
But do you mean that if I want a persistant line I should keep the point variables all along the program?
and also you suggest that the line should be drawn in the OnPaint event but is it the only way? I need to create the line as a response to an other events, so what is the right way?
Thanks,
|
|
|
|
|
lune12 wrote: what is the right way?
I just indicated the right way.
if you want to change the drawing, then change the data and call Control.Invalidate() to request an automatic repaint.
|
|
|
|
|
Thanks, it's working but isn't it a waist of time to redraw all the line each time that the paint event is invoked?
|
|
|
|
|
you could reduce the amount of work executed by taking into account the clipping data that is present in the PaintEventArgs/Graphics. IMO that is worthwhile only in special cases, like complex paintings that need frequent repaints (e.g. as in games, which probably get programmed quite differently anyhow).
|
|
|
|
|
CreateGraphics is temporary. Use e.Graphics and the Form.Paint event instead. You also appear to have a syntax error (two brackets in front of Pens.Red)
|
|
|
|
|
|
i have already saved username,password in login table.if i entered username,password in login_form, valid user only access that form.how will i do.plz help me
|
|
|
|
|
Write a Stored Proc which will accept two params i.e. your entered username and password, then compares it with the database and returns the status (success/failure). Execute this SP for authentication.
Before doing that go to the nearest book store, buy some good book and learn the basics.
|
|
|
|
|
|
demetter wrote: plz give me the code
Firstly, thats not how it works here. You write the code, and when it doesn't work we help with specific problems. Otherwise, you never learn anything.
Secondly, how are we meant to do that without knowing anything about your database - most people on here are not mind readers, although it does help with some of the questions.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
this code i have used.database is msaccess(mdb)
private void btn_login_Click(object sender, EventArgs e)
{
try
{
string UserName,password,txtPassword;
UserName = txt_user.Text.ToString();
password = txt_pwd.Text.ToString();
//Query = "insert into Login (UserName,txtPassword ) values ('" + UserName.ToString() + "','"+ password.ToString() +"' )";
//daSet = dd.ExcuteDataSet(Query.ToString());
//MessageBox.Show("Successfuly Saved..!");
Clear();
if (UserName == ds.Tables["Login.UserName"].ToString())
if (password == ds.Tables["Login.txtPassword"].ToString())
{
MessageBox.Show("correct");
}
else
{
MessageBox.Show("incorrect");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
modified on Friday, April 17, 2009 8:38 AM
|
|
|
|
|
You need to learn a bit about sql before you go any further. Try searching CP for aricles about using access and c#. Do you understand how a database stores data and how to retreive it? It doesn't look like it from the above.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
hi ,
i am using this code to insert a record into data table
objCommand = new OleDbCommand(str, objConnection1);
objCommand.Parameters.Add("@sid", OleDbType.Integer);
objCommand.Parameters.Add("@nm", OleDbType.VarChar, 255);
objCommand.Parameters["@sid"].Value = textBox1.Text;
objCommand.Parameters["@nm"].Value = textBox2.Text.Trim();
objConnection1.Open();
data = objCommand.ExecuteNonQuery();
it works and it display that record in the grid when i reload data grid.
<b>BUT the the record does not store permanently in the table.</b>
IT dose not display that record when i restart the application.
what is the problem...
|
|
|
|
|
What kind of database do you use? MS Access? Did you checked for the AutoCommit-flag? I'm just guessing, but maybe the internal transaction is not committed.
Regards
Sebastian
|
|
|
|
|
Hi after posting this threat i got the solution
in the solution Explorer first i selected the mdb file;
then changed the properties of mdb file.that is
copy to output directory : copy if newer
that's it !!
|
|
|
|
|
Hi
I know generally we add return confirm message at deleting. But I need to do it at uploading. I can not call the return confirm message from the button onclick because I am validating when uploading. so i need the return confirm message after validation
Can any body help?
|
|
|
|
|
Your question is not clear.., for the delete/updation/adding conformation Message box logic is same..,
Use this below code is U R requirement is same as below...
if (MessageBox.Show("Are U Sure???") == MessageBoxButtons.OK)
// upload process here
else
// terminating process here
Thanks
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
Hello,
I have an excel file with a specefic characters, when i read the text from excel and write it on txt file, the text was on ????????, i do this :
<br />
workbook = excelApplication.Workbooks.Open(@"C:\1.xls", 0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);<br />
worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Worksheets[1];<br />
<br />
string cell_nom = "";<br />
object cellObject_nom = null;<br />
<br />
for (int i = 2; i <= worksheet.UsedRange.Columns.Count; i++)<br />
{ <br />
<br />
range_nom = (Microsoft.Office.Interop.Excel.Range)worksheet.Cells[i, 2];<br />
cellObject_nom = range_nom.get_Value(null);<br />
cell_nom = (cellObject_adr5 == null ? "" : cellObject_adr5.ToString().Trim());<br />
<br />
Console.write (cell_nom);<br />
<br />
}<br />
the original text in excel file was Ангел Димитров Мисирджиев ,
Please help me,Thank you verry mutch
|
|
|
|
|
Hello,
I try fot :
<br />
byte[] l = Encoding.Default.GetBytes(cell_nom);<br />
string f = Encoding.UTF8.GetString(l);<br />
MessageBox.Show(f);<br />
<br />
But unfortunatly it doesn't work, there are always ??????????????, help me please, thank you verry mutch
|
|
|
|
|
Hi,
Can i able to change the installation URL without publish
eg;
i already publish to a URL and i need to change the URL with out open the solution or by without clicking publish, Can i give the URL in web.config or some other way?
Is it possible?
Thankyou
YPKI
|
|
|
|