|
I declared it as an array so that I could have a series of a hundred points connected by the DrawCurve. Is there an easier way to do this?
When I replace new Point(...) with new PointF(...), I get a similar problem message.
Value of type 'System.Drawing.PointF' cannot be converted into '1-dimensional array of System.Drawing.PointF'.
I'm not sure what dimension why PointF isn't considered 1-dimensional. Please advise.
Thanks for replying Luc.
B.T.
|
|
|
|
|
Hi Billy,
1.
this does not make sense; the error message "Value of type 'System.Drawing.PointF' cannot be converted into '1-dimensional array ..."
would fit the statement PolyPoints = New PointF(Counter, G * ((Counter) ^ 2) + H * ((Counter) ^ 3))
but yours has/had the index (Counter)
2.
there is another error too, you can't take a textbox text and store it in an integer like
that. You would need something like G = Convert.ToInt32(TextBox1.Text) .
3.
Furthermore if an invalid number is entered (empty, letters, whatever), the code would
throw an error; either provide a try catch construct, or use Int.TryParse or so.
4.
I reckon you want two distinct textboxes for G and H?
5.
You probably want to use floating-point numbers for G and H (and Float.TryParse),
otherwise there is no sense in using PointF and your graphics will not fit your panel...
-- typo corrected at 20:04 Monday 19th November, 2007
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi Everyone:
I'm trying to teach myself VB 2005 .NET and the best way I have found to learn something is to make a project in the language I wish to learn.
I'm playing with a graphics Windows application. I want to draw a simple graphics shape(rectangle, circle, line, etc) on a windows form and be able to move that graphics object anywhere on the form using the mouse.
Does anyone have any sample code that can draw a shape on the windows form and allow to move it with the mouse, or arrow keys?
Thanks in advance,
Quecumber256
|
|
|
|
|
If you want to learn, you would be better off writing the code yourself. How are you going to learn anything if someone else writes the code for you?
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
There are no built-in classes to do this, not is there any support built into GDI for this either.
What you're referring to is a "retained mode" graphics system. This is something that you either have to write yourself (WARNING! NOT for someone who has little experience!), or use a third party library to handle it for you, like VG.NET.
|
|
|
|
|
Dave:
Thank you. I have had some discussions with our .NET developer here at the office and he put some things in perspective for me.
For example: I drew a square on the windows form. That would be level 1. Next I drew a circle on top of the square, this is level 2. So if I click on the circle I have to have some routine that looks at the levels and sees where the cursor is pointing, which level it is on, and then place some kind of "visual handlers" around the object then use another routine to move it on the form.
This helps me grasp the concept of what I'm trying to accomplish.
Do you have any recommendations for books that cover graphics manipulation and programming for VB .NET?
Thank you,
Quecumber256
|
|
|
|
|
Hi! Please help me in finding a component which can be used to generate a pdf file or even a tiff file from a template of these formats so that I can replace existing place holders in the template with the values. I'm using Visual basic 6 for this purpose.
Any help is appreciated. Thanks!
Don't Quit
|
|
|
|
|
|
Hi Pete! Thanks for your reply! But I'm looking for a COM component. Do you have any idea?
Thanks in advance!
Don't Quit
|
|
|
|
|
Nitin1981 wrote: Hi Pete! Thanks for your reply! But I'm looking for a COM component. Do you have any idea?
Try the Adobe Acrobat SDK for that:
http://www.adobe.com/devnet/acrobat/[^]
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
I have a combo box on form FrmFinance and it has lots of values and a "Other" selection. If you select it, a dialog window opens, Dialog1. What I want is that on Dialog1 form there is a textbox called txtMake and when you press OK btnOK on the dialog1 form, the item gets added to cmbmake (combo box) on FrmFinance. I don't want any values removed from the combobox, just add what is in the textbox when you press OK
Any ideas?
In the end we're all just the same
|
|
|
|
|
At Last found the solution to this problem previously I was also facing somewhat similar problem here is the solution which worked for me.
In your form2 declare a Class level variable of form type e.g.
Dim oForm as Form
now in the Load event of form2 just make this equal to the 'ActiveForm' property of frmFinance e.g.
oForm = frmFinance.ActiveForm
Now just enter the following code in the Button Click event handler or in whatever event you want to use in order to add items to the Combobox e.g.
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
CType(oForm, frmFinance).cboMake.Items.Add(Me.txtMake.Text)
End Sub
As it helped me I hope it help you too... Good Luck !
AliAmjad(MCP)
First make it Run THEN make it Run Fast!
|
|
|
|
|
OK, but maybe you also want:
- to make sure the value is not already present;
- sort the values;
- remove some when there are too many values.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I got that to work, just changed "Dim oForm as Form" to "Public oForm as Form", thanks. Now how would I remove all items I added to combo box without removing all items? Also, when you click button, I want the combobox to focus on the new added item
In the end we're all just the same
|
|
|
|
|
i m using Smtp for sending mail. I m getting body text from an html editor. This editor uses webbrowser control. Problem is this, when i put an image on the webbrowser control and send it to a mailing address it don't show the pic but all the test is ok.
here's the code i use.
Dim MailObj As Net.Mail.MailMessage = New Net.Mail.MailMessage()
MailObj.To.Add("sampleemailaddress@exampledomain.com")
MailObj.From = New Net.Mail.MailAddress("myemailaddress@somedomain.com", "King")
mailObj.Priority = Net.Mail.MailPriority.Normal
MailObj.Subject = "This is test mail"
mailObj.Body = WebBrowser1.DocumentText
Dim smtpcli As Net.Mail.SmtpClient = New Net.Mail.SmtpClient("smtp.gmail.com", 587)
smtpcli.EnableSsl = True
smtpcli.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
smtpcli.Credentials = New Net.NetworkCredential("someemailaddress@gmail.com", "password")
Try
smtpcli.Send(MailObj)
MsgBox("Email successfully delivered.")
Catch ex As Exception
MsgBox(ex.ToString())
End Try
Thx in advance for any help.....
King
|
|
|
|
|
Try and change the mail type to HTML and then you can send anything formatted well in HTML.
Mubashir
Software Architect
Storan Technologies Inc, USA
Every job is a self portrait of the person who did it.
|
|
|
|
|
Just declare a MailAttachment object give the path of Image to its constructor and then Add it into the Attachment collection of your Mail Message object e.g.
Dim imgAt As New MailAttachment("ImagePath")
MailObj.Attachments.Add(imgAt)
Good Luck !
AliAmjad(MCP)
First make it Run THEN make it Run Fast!
|
|
|
|
|
I am having a problem with the MemberUsername record in my datMember table.
I got the error "IndexOutOfRangeException Was Unhandled by user code when i tried to run my application.
I double check the database.
I declare the MemberUsername as varchar 50
Is tat cause the IndexOutOfRange?
I also have checked the uppercase and lowercase letter too..Nothing is wrong with that..
What would be the problem?
Your help is very much appreciated to me as a beginner..thanks a lot.
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim conMbr As New SqlConnection
Dim cmdMbr As New SqlCommand
Dim sqlReader As SqlDataReader
Dim strVerifyMbr As String
conMbr = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename='C:\Program
Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\GpsCinema.mdf';Initial Catalog=GpsCinema;Persist Security Info=True;User ID=sa;Password=password;MultipleActiveResultSets=True;Connect Timeout=30;User Instance=False;Context Connection=False")
conMbr.Open()
strVerifyMbr = "SELECT MemberId FROM datMember WHERE memberUserName='" + txtUserId.Text + "' AND memberPassword='" + txtPwd.Text + " '"
cmdMbr = New SqlCommand(strVerifyMbr, conMbr)
Dim checkUsr As String = ""
sqlReader = cmdMbr.ExecuteReader
While sqlReader.Read
If txtUserId.Text = Convert.ToString(sqlReader("MemberUsername")) Then
If txtPwd.Text = Convert.ToString(sqlReader("memberPassword")) Then
Session("username") = sqlReader("memberUsername")
Session("password") = sqlReader("memberPassword")
Server.Transfer("MainUser.aspx")
Else
Response.Write("window.alert('Invalid Password. Please try again.');<" + "/script>")
Server.Transfer("MainUser.aspx")
End If
End If
checkUsr = "Failed"
End While
If checkUsr = "Failed" Then
Response.Write("<SCRIPT lanquage='JScript'>window.alert('Invalid Username! Please Try Again.');<" + "/SCRIPT>")
Server.Transfer("MainUser.aspx")
End If
conMbr.Close()
End Sub
<div class="ForumSig">Life is up and down
Nevertheless,never give up hope and be confident to yourself</div>
|
|
|
|
|
kc_renji wrote: What would be the problem?
What line is causing the exception? You didn't say.
kc_renji wrote: strVerifyMbr = "SELECT MemberId FROM datMember WHERE memberUserName='" + txtUserId.Text + "' AND memberPassword='" + txtPwd.Text + " '"
The above line is using SQL Injection. It is vulnerable to attack. Please read SQL Injection Attacks and Tips on How to Prevent Them[^]
kc_renji wrote: Session("password") = sqlReader("memberPassword")
Why do you need to store the password in the session. This is privileged information, it shouldn't be passed around so freely. It would be better to store the password as a salted hash and compare the hash values.
kc_renji wrote: Response.Write("window.alert('Invalid Password. Please try again.');<" + "/script>")</blockquote>
Never tell the user this much detail. It is a security risk. Tell them that the user name and password don't match.
Also, you shouldn't have database code in the presentation layer. There is no protection for the connection or reader in case something fails with the database interaction (i.e. you have no Try/Catch/Finally blocks)
<div class="ForumSig"><hr><small>Upcoming FREE developer events:
* Developer! Developer! Developer! 6
* Developer Day Scotland
<b>My <a href="http://www.colinmackay.net">website</a></b></div>
|
|
|
|
|
This line cause the error..
If txtUserId.Text = Convert.ToString(sqlReader("MemberUsername")) Then
Thanks
Life is up and down
Nevertheless,never give up hope and be confident to yourself
|
|
|
|
|
I think I've seen the problem.
Your query is SELECT MemberId ...
You are then attempting to read memberUsername and memberPassword from the query. These don't exist.
Upcoming FREE developer events:
* Developer! Developer! Developer! 6
* Developer Day Scotland
My website
|
|
|
|
|
so the query would be SELECT memberUsername and memberPassword and delete the WHERE query?
Life is up and down
Nevertheless,never give up hope and be confident to yourself
|
|
|
|
|
kc_renji wrote: so the query would be SELECT memberUsername and memberPassword and delete the WHERE query?
WHERE is not a query, it is a clause of the SELECT query.
Your query should be what works. Your current query and code do not match. They need to match. From what I've seen of your code neither are robust enough to form a good solution.
Upcoming FREE developer events:
* Developer! Developer! Developer! 6
* Developer Day Scotland
My website
|
|
|
|
|
Erm i am not really understand that
Since the user enter their name and password
Should the query would verify if the name and password entered would match their memberID???
If not..what should i do?
Life is up and down
Nevertheless,never give up hope and be confident to yourself
|
|
|
|
|
kc_renji wrote: Should the query would verify if the name and password entered would match their memberID???
If not..what should i do?
I've already given you lots of advice.
Your query should not be returning passwords. It should probably just be returning the MemberID. If no rows are returned then obviously the login has failed.
You should store the memberID in the session as that will be connected to other parts of the system. (Assuming the database is well designed)
You should follow the other advice I've given, especially about SQL Injection Attacks. Your code is very weak and quite vulnerable to attack.
Upcoming FREE developer events:
* Developer! Developer! Developer! 6
* Developer Day Scotland
My website
|
|
|
|