|
With extreme difficulty. AFAIK, there is no component to interact with OWA.
|
|
|
|
|
I use DataGridView with column type CheckBox. How to verify whether CheckBoxs in this column is checked
|
|
|
|
|
Get the CheckBox cell and inspect its checked property. A bit more explanation of your problem would help.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
How to inspect. Give me some example
|
|
|
|
|
ivo75 wrote: How to inspect
The checked property is a boolean. Put that in a if/else block and see if it is true or false. Not a VB guy hence cannot provide the code. Even if I was, I wouldn't have since I do not believe in spoon feeding at professional level (Hope you are a professional and not a student).
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
test whether the checked property is true to do whatever you want
|
|
|
|
|
Hello,
I am programming in vb.net 2005
I have two classes: Point and Line
My application is drawing ~30 to 50 lines on a picturebox.
I don't know if it is possible but I am trying to add an eventhandler to allow user to click on specific line and then to change the color of selected line.
I can't success to give to this line object a click event ability.
Is it possible?
How to do it?
Here is my snippet code:
Option Explicit On
'********START POINT*******************
Public Class MainForm
Private Line1 As Line
Private Sub MainForm_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim P1 As New Point(10, 30), P2 As New Point(120, 210)
Line1 = New Line(P1, P2)
Line1.DrawLine(e)
AddHandler Line1.LineClick, AddressOf LineClicked
End Sub
Private Sub LineClicked(ByVal sender As Object, ByVal e As EventArgs)
'Do something
End Sub
End Class
'********DELEGATE*******************
Public Delegate Sub LineEventHandler(ByVal sender As Object, ByVal e As EventArgs)
'********LINE CLASS*******************
Public Class Line
Inherits EventArgs
Private P1 As Point, P2 As Point
Sub New(ByVal P1 As Point, ByVal P2 As Point)
Me.P1 = P1
Me.P2 = P2
End Sub
Sub New(ByVal x1 As Single, ByVal y1 As Single, ByVal x2 As Single, ByVal y2 As Single)
Me.P1 = New Point(x1, y1)
Me.P2 = New Point(x2, y2)
End Sub
Public Sub DrawLine(ByVal e As PaintEventArgs)
Dim p As New Pen(Color.Black, 1)
Dim g As Graphics = e.Graphics
g.DrawLine(p, P1.x, P1.y, P2.x, P2.y)
End Sub
Public Event LineClick As LineEventHandler
Protected Overridable Sub OnLineClick(ByVal e As EventArgs)
RaiseEvent LineClick(Me, e)
End Sub
End Class
'********POINTC CLASS*******************
Public Class Point
Public x As Single, y As Single
Sub New(ByVal x As Single, ByVal y As Single)
Me.x = x
Me.y = y
End Sub
Property xCoord() As Single
Get
Return x
End Get
Set(ByVal value As Single)
x = value
End Set
End Property
Property yCoord() As Single
Get
Return y
End Get
Set(ByVal value As Single)
y = value
End Set
End Property
End Class
Shay Noy
|
|
|
|
|
Well, there are a few problems here. Your class line does not need to inherit from EventArgs. Instead it should inherit from Control/Usercontrol class since controls raise event. Next, the EventArgs can be replaced by LineClickEventArgs and that class should inherit from EventArgs class. This class should have properties that the parameter should provide. Then, you need to have a virtual overridable method say OnLineClick which should take in LineClickEventArgs as the parameter.
The only thing that remains now is that from where will you call OnLineClick. For this, you will need to identify if the click was on the line. You can have some property that will be set when you click the line. And in the set block, you can call the OnLineClick method.
AFAIK you can get to know if the line was clicked only in the MouseDown/MouseUp of your form. And there you can change the property of the Line class which will raise the event.
Other way of changing the line color can be this:
1. In the MouseDown/MouseUp event of the form, see if click was on line.
2. Have a flag say IsLineClicked in your form.
3. Add a bool parameter in your DrawLine and in the method have an if else that will set the color in which line will be drawn.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
|
Welcome.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
I have written a program in VB 2008 Express to call up my ADSL Router, login, access and save some traffic statistics. The partial code shown below has been gleaned from the interent/forums as a means to automatically login to the router. Unfortunately, this routine does not work. When the webbrowser1.navigate command is issued the router responds with another form requiring the login user name and password (these are required in unencrptyed text). The document.completed event is never reached as control is taken away from my program and held by the Internet Explore pop up page. I have tried a number of ideas but cannot overcome this proble. Is there an experienced coder who can offer some valuable advise please ?
code:
Imports System
Imports System.Net
Public Class Form1
Dim username, pswd As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Part 1: Use WebBrowser control to load web page
WebBrowser1.Navigate("http://192.168.1.1/")
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
username = "admin" : pswd = "admin"
' Part 2: Automatically input username and password
Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
For Each curElement As HtmlElement In theElementCollection
Dim controlName As String = curElement.GetAttribute("name").ToString
If controlName = "username" Then
' curElement.GetAttribute("Value")
curElement.SetAttribute("Value", username)
ElseIf controlName = "password" Then
curElement.SetAttribute("Value", pswd)
End If
Next
' Part 3: Automatically click the Login button
Dim theWElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
For Each curElement As HtmlElement In theWElementCollection
If curElement.GetAttribute("value").Equals("Login") Then
curElement.InvokeMember("click")
' javascript has a click method for we need to invoke on the current submit button element.
End If
Next
End Sub
End Class
|
|
|
|
|
In this case, the NetworkCredentials class won't do you any good. You'll have to navigate to the Login Form as normal, then in the browsers Document class, find the two textboxs for username and password, set their appropriate values, then "click" the submit button.
No, I don't have example code. I never do interaction with Web Pages.
|
|
|
|
|
Thanks for your answer Dave. It looks as though I will abandon this project in Visual Basic and move over to Pearl as this can be achieved with that language.
|
|
|
|
|
The original message was a clr20r3 message - clr20r3, P1 getmetsatdata.exe, P2 2.1.21.5, P3 4ad621e6, P4 getmetsatdata, P5 2.1.21.5, P6 4ad621e6, P7 20, P8 c6, P9 system.invalidoperationexception, P10 NIL.
I have searched the Internet, and here, and got lots of answers as to how to find out what this error is and have managed to get the program to create a text file on hitting the unhandled exception which tells me this is a 'network path not found error', so I got it to output the stack trace which tells me this:
17/10/2009 11:34:12
Unhandled exception on start up
at GetMetSatData.My.MyProject.MyForms.Create__Instance__[T](T Instance)
at GetMetSatData.My.MyProject.MyForms.get_FGetMetSat()
at GetMetSatData.My.MyApplication.OnCreateMainForm()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
This does not happen of the development machine by the way , but on 2 (or more) XP machines on which it has been installed.
My problem is that I have absolutely no idea what 'network path' this is referring to!
|
|
|
|
|
Not enough information to answer the question.
What do the app do?? What does the app do on startup?? Are you using any threading in the app?? What is going on in the threaded sections??
|
|
|
|
|
The app collects satellite pictures from the EUMETSAT site. On startup it checks the registry, but it never gets as far as that as it crashes even before it writes the first event log entry. There is no threading.
Private Sub FGetMetSat_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim intLoop As Integer = 0
Dim listErrors As New List(Of String)
Try
EventLog1.WriteEntry("MetSatGetter " & Application.ProductVersion & " was started: " & Now.ToString, EventLogEntryType.Information, 60000)
If RegistrySet() = False Then
Dim myKey As RegistryKey = My.Computer.Registry.CurrentUser.OpenSubKey("Software\DA Software\MetSat\Imagery\MSG\IR039\COL\AMERICA", False)
If myKey Is Nothing = True Then
'We may have a problem here - false overwrite
listErrors = Registry_Setup()
If listErrors.Count > 0 Then
SaveErrorList(listErrors)
End If
Else
If MsgBox("Problem: Your settings are indicating that the program registry was not installed, but one of the keys was found possibly indicating " _
& "that registry entries have been removed, or some other problem has occurred." & vbCrLf & vbCrLf _
& "MetSatGetter will now re-create the keys unless you click 'Cancel'. Note recreating the keys will overwrite any settings.", _
MsgBoxStyle.OkCancel + MsgBoxStyle.Critical, "Met Sat Getter") = MsgBoxResult.Cancel Then
'User is cancelling
m_bRegLoadError = True
For intLoop = 0 To Me.cmsMain.Items.Count - 2
Me.cmsMain.Items(intLoop).Enabled = False
Next
MsgBox("Please wait for the program to terminate. This should happen in about 1 minute, or you can terminate it yourself.", MsgBoxStyle.Information, "Met Sat Getter")
Else
listErrors = Registry_Setup()
If listErrors.Count > 0 Then
m_bRegLoadError = True
SaveErrorList(listErrors)
Else
ParseTasks()
Me.trayIcon.Text = "Met Sat Getter - " & Tasks.Count.ToString & " tasks active"
End If
End If
End If
Else
ParseTasks()
Me.trayIcon.Text = "Met Sat Getter - " & Tasks.Count.ToString & " tasks active"
End If
TempDump = SettingsKey.GetValue("TempFolder", "")
DefaultDump = SettingsKey.GetValue("DefaultFolder", "")
Me.tmrMain.Enabled = True
Me.WindowState = FormWindowState.Minimized
Catch ex As Exception
EventLog1.WriteEntry("MetSatGetter error: " & ex.Message, EventLogEntryType.FailureAudit, 60112)
EventLog1.WriteEntry("MetSatGetter failed on the load routine: " & Now.ToString, EventLogEntryType.Information, 60112)
End Try
End Sub
|
|
|
|
|
OK, all of this looks decent. I'd move on to the Form's constructor (New method) and whatever is in the InitializeComponent method. This could mean that you have a problem with a control on the form.
|
|
|
|
|
The programmer had sat at his machine most of the weekend so far tearing out his hair and burning the midnight oil. He looked though every single line of code, those produced by him and those produced by VS.
Nothing, no answers. Every run on a different machine failed.
On Sunday he received a mail from Dave Kreskowiak, a coder supreme, a God amongst programmers. Heartened that Dave thought his code looked OK, the programmer was never the less still tearing his hair out.
Dave said "and whatever is in the InitializeComponent method". Huh? He thinks I have not looked at that a million times. OK, well one last time.
The programmer saw something, and hung his head in abject shame. If this was the cause of several days of heartache he deserved a good kicking. In the EventLog control property he had filled the name of the LocalMachine with his machine's name! Was this the cause ----> Oh yes it was. Once replaced with a dot everything worked.
The programmer gave thanks to Dave , groveling on the floor before the greatness of the man and thinking, my name may be as his, but it will be many years before I aspire to such greatness. He then went out side to kick himself thoroughly.
|
|
|
|
|
TheComputerMan wrote: a God amongst programmers
Hardly. But, I am willing to accept a sacrifice!
TheComputerMan wrote: Dave said "and whatever is in the InitializeComponent method". Huh? He thinks I have not looked at that a million times. OK, well one last time.
2 clues pointed in that direction after seeing the code. First, the error you originally posted was an unheandled exception. Second, you said it never made an event log entry. That was pretty much the first line of code in the Load handler, so it appears that it never got this far.
The order for execution of a Form start's with the contructor, then goes to InitializeComponent, then the Load event is raised, where your Load handler gets called. Those two clues says that either the New method (constructor) failed, but it's rare to find code in a Form's New method, or in InitializeComponent, which New calls by default. Also, You normally don't find Try/Catch blocks in InitializeComponent so the exception most likely came from there.
TheComputerMan wrote: groveling on the floor before the greatness of the man
You can get up now. I work for a living. I can only wish I could sit around and have my wife feed me grapes all day.
|
|
|
|
|
Log the entire ex.ToString() , the stack-trace could contain some clues.
Create a dummy-testapplication that writes the text "Hello World" to the event-log. Ditto for the registry
I are Troll
|
|
|
|
|
You're getting an error in the form FGetMetSat's constructor (I think). Beyond that, I've got no idea. More information please?
|
|
|
|
|
Hi there,
I have a prolem which is quite annoying which one of you right people might be able to tell me how to do very simply
I have a program which i have nearly completed, but to stop piracy i am having a txt file which reads the data from the program to see if the serial number is correct. HOWEVER i got so far however when the serial number is inputted "form2" is loaded and that works fine, but when i reload the program i don't want the CD key login form to re-appear. The form2 appears but in a flash (I have a slow computer so nottice that it is a form2). I have tried editing all aspects of the code but if any body could help me that would be cool
Here is the code if you want to look at it.
I used 1 button
1 text box
1 check box - supposed to be that if this is checked that it doesn't show this form
1 label
1 txt document in the debug\bin\labeled serial.txt
Public Class Form1
Dim FILE_NAME As String = ("serial.txt")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim objReader As New System.IO.StreamReader(FILE_NAME)
Do Until objReader.EndOfStream
If txtserial.Text = objReader.ReadLine Then
Startnot.Checked = False
Form2.Show()
Me.Hide()
Else
Try
If txtserial.Text = objReader.ReadLine.Trim Then
End If
Catch Ex As Exception
End Try
Label1.Text = "Invalid CDKey"
End If
Loop
objReader.Close()
End Sub
Private Sub Form1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Leave
If Me.Visible = False Then
Form2.Show()
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SetAttr(FILE_NAME, FileAttribute.Normal)
Dim Dontshow As Boolean
Dontshow = GetSetting(My.Application.Info.ProductName, "Options", "Dont Show Me", 1)
If Dontshow = 0 Then
Form2.Show()
Call cookies()
Exit Sub
End If
Startnot.Checked = True
End Sub
Private Sub Startnot_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Startnot.CheckedChanged
SaveSetting(My.Application.Info.ProductName, "Options", "Dont Show Me", Startnot.CheckState)
End Sub
Private Sub cookies()
Me.Close()
My.Forms.Form2.Show()
End Sub
End Class
|
|
|
|
|
Let me get this straight. Your putting the CDKey that the user has to input into a text file and shipping that with the application. When the user launches the app, they have to type the key in and that is compared to the key in the text file to see if the program will run. Do I have that correct??
|
|
|
|
|
Yes. There will already be serial keys in the .txt file e.g BC3 and if the user puts in BC4 that will b compared to the .txt file and bring back an error message saying. Nope were not letting you in.....
|
|
|
|
|
This is a complete waste of time. What's to stop the user from opening the text file in Notepad and entering what's in the text file?? Hint: Nothing!
Also, if the user want to copy the app to another machine without buying another copy, there is nothing stopping the user from copying the serial number file he already has!
Your copy protection scheme is never going to work.
|
|
|
|
|