|
Upgrading VB6 to .NET has been so pleasant.... NOT
In VB6 I could make a control array, when an operator clicked on an element I could set a variable that told me which control it was then I could pop up a menu where the user selected a menu item. When they did I looked at the control they were pointing to and did what I needed to do. (I have 100+ slots and the user needs to be able to look an a particular one, each of which is represented as a label or text box on screen)
OK in .NET, no control arrays, so I build 100+ controls manually, then I arrange them on screen (each configuration could be different), once again hundreds of lines of code as there are no arrays, then I try to trap the one clicked for the popup menu, my next joy has arrived....
I was hoping that someting like this would work:
Private Sub lblSlots5_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblSlots5.Click
g_selectedslot = 5
End Sub
The hope being I would set g_selectedSlot before the menu pops up... for some reason it does not seem to work that way.
Yes, I did try MouseHover and MouseDown.
any ideas?
Thanks in advance, the rest of my bottle of Advil to anyone who can help...
|
|
|
|
|
I'm new to .NET myself after years of VB programming (4 and up) and that's my biggest complaint about .NET is the events appear to be fired in a really haphazard fashion (my personal biggest pet peeve is Form_Load may or may not be the first event to fire).
You can create one event to handle all of the mouseclicks by adding them to the event:
Private sub MouseClick(Byval sender as...) handles lblSlot1.Click, lblSlot2.Click, lblSlot3.click, ...
MsgBox("Label Clicked = " & sender.Name)
End Sub
Personally, I would ask someone here show you how to create controls at run time and assign them to an event handler, I'm a little fuzzy as to how to do that myself.
|
|
|
|
|
control array:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
Dim poLbl() As Label<br />
Dim piIndex As Integer<br />
Dim piX As Integer<br />
Dim piY As Integer<br />
<br />
ReDim poLbl(5)<br />
piX = 10<br />
piY = 10<br />
For piIndex = 0 To 5<br />
poLbl(piIndex) = New Label<br />
poLbl(piIndex).Parent = Me<br />
poLbl(piIndex).Height = poLbl(piIndex).Font.Height<br />
poLbl(piIndex).Left = piX<br />
poLbl(piIndex).Top = piY<br />
poLbl(piIndex).AutoSize = True<br />
poLbl(piIndex).Text = "Dynamically Created " & piIndex<br />
poLbl(piIndex).Visible = True<br />
poLbl(piIndex).Tag = piIndex.ToString<br />
AddHandler poLbl(piIndex).Click, AddressOf ClickHandle<br />
piY = piY + poLbl(piIndex).Height + 5<br />
Next<br />
End Sub<br />
<br />
Public Sub ClickHandle(ByVal sender As System.Object, ByVal e As System.EventArgs)<br />
MsgBox("Clicked #" & sender.Tag)<br />
End Sub
|
|
|
|
|
Perfect, now if I can just figure out the menu thing... thanks
|
|
|
|
|
Hello,
I am tring to return a employee object to my GUI Page from a dataaccess page. Every thing seems to do fine until the function try's to return the employee object from the Ordional Postion of (0) from the EmployeeList Innerlist. I am getting stuck on the GET and the Return CType(Me.Item(index), Employee) . Wehn i step into the code It just goes back and forth like it is stuck or something. Like a broken record.. And when i just run the application i get an error message that there is a overflow error.
Can someone please look at this and let me know where i need to make chages?
I can post all of the code if i need to..
Thanks,
Erik,..
If you will look below; this is where i am tring to return the employee object
Default Public ReadOnly Property Item(ByVal index As Int32) As Employee
Get < ******Stuck here********
Return CType(Me.Item(index), Employee) < ***** AND HERE
Gui....................................
Dim EmpAss As New EmployeeAccess
ddl.DataSource = EmpAss.PopEmployee(2)
ddl.DataBind()
------------------------------------------------------------
DataAccess-----------------
Public Function PopEmployee(ByVal Empid As Int32) As Employee
PopEmployee = GenericDataAccess("Employee_Byid", "@Employeeid", Empid)
End Function
'
'
Dim Emp_Data_List As New EmployeeCollections
Private Function GenericDataAccess(ByVal CommandText As String, _
ByVal ParamName As String, _
ByVal ParamValue As String) As Employee
With Data_Connection
.Open()
End With
'
With Data_Command
.CommandText = CommandText
.CommandType = CommandType.StoredProcedure
With Data_Command.Parameters
.Add(ParamName, SqlDbType.Int, 4).Value = ParamValue
End With
.Connection = Data_Connection
End With
'
Data_Reader = Data_Command.ExecuteReader
While Data_Reader.Read
Emp_Data_List.Add(New Employee(Data_Reader("FirstName"), _
Data_Reader("LastName"), _
Data_Reader("City"), _
Data_Reader("Employeeid")))
End While
With Data_Connection
.Close()
End With
'
With Data_Reader
.Close()
End With
'
With Data_Command
.Dispose()
End With
'
Return Emp_Data_List(0)
'
'
End Function
===================================================
CollectionBase---------------------------------
Public Class EmployeeCollections : Inherits CollectionBase
Public Function Add(ByVal Employee As Employee) As Int32
Return Me.InnerList.Add(Employee)
End Function
'
Default Public ReadOnly Property Item(ByVal index As Int32) As Employee
Get
Return CType(Me.Item(index), Employee)
End Get
End Property
End Class
|
|
|
|
|
i m using wmi to connect my pc to remote comp.
but getting an error. Access is denied .
pls help me out!!
thnx in advance
// code of connecting PCs is as folows..
Dim objWMIService As ManagementObjectSearcher
Dim colQuotas As System.Management.ManagementObjectCollection
Dim objQuota As System.Management.ManagementObject
Dim path As ManagementPath
Dim scope As ManagementScope
path = New ManagementPath(String.Format("\\{0}\root\cimv2", "192.168.1.110"))
scope = New ManagementScope(path)
Try
scope.Connect()
Catch ex As ManagementException
' Failed to authenticate properly.
MsgBox("Failed to authenticate: " + ex.Message)
' Return Status.AuthenticateFailure
Catch ex As System.Runtime.InteropServices.COMException
' Unable to connect to the RPC service on the remote machine.
MsgBox("Unable to connect : " + ex.Message)
'Return Status.RPCServicesUnavailable
Catch ex As System.UnauthorizedAccessException
' User not authorized.
MsgBox("Unauthorized access: " + ex.Message)
End Try
objWMIService = New ManagementObjectSearcher(scope, New ObjectQuery("Select * from Win32_ComputerSystem"))
colQuotas = objWMIService.Get
For Each objQuota In colQuotas
HostName = objQuota.GetPropertyValue("Name").ToString()
Next
*AnNiE*
|
|
|
|
|
hi there,
Take a look on this link
WMI
this might give u a hint...
<< >>
|
|
|
|
|
does anyone know how to resize the graphics objects (rectangles, ellipses etc...) after the user creates them ? preferrably with a standard handle container....
|
|
|
|
|
codecreeper wrote:
preferrably with a standard handle container....
sorry, wat do u mean here?
u mean that u want to do something like a Paint program in which user can draw some objects (rec, ellipse,..) then he can resize these objs?
if so, the way to achieve this that u have to store these objs in an array. Then u hv to repaint these objs if user resize...
<< >>
|
|
|
|
|
Yes by creating the reize method.Contact me for further assistance
Hi i am sumod
|
|
|
|
|
Is anybody developing apps/components that are OPC compliance. I just wanted to know if OPC is still alive and it's used as standard for industrial client / server applications.
Marc Soleda.
P.d: I've asked the same question in the VC++ forum but as it can be applied in any development platform I decided to ask it here.
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
I am very carefull about declaring variables. But in a project i get out of memory exception, generally after close a form i use GC.Collect.
In this project , I connect a Sql Server with a sqlConnection declared as public in a module. Because in every task, i use this connection object. Before task i open that, when i achive the task, i close the connection. can This be cause?
|
|
|
|
|
Greeky wrote:
Before task i open that, when i achive the task, i close the connection. can This be cause?
Nope, I think.
To easily figure out somthing. U might post ur snippet code that cause this problem. Or u might try to debug it.
<< >>
|
|
|
|
|
Are you showing forms using .ShowDialog() ? Are you calling .Dispose() on these forms? If not, your memory problems are coming from running the system handle pools into the ground. This also applies to Bitmaps, Pens, Graphics objects, ..., ...
Also, you should NOT be caling GC.Collect unless you have very specific reasons for doing so. The GC is self-tuning and calling it without knowing what the side effects are can also result in memory issues.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am being call by a C DLL which suppliies a pointer to a structure. I have defined the parameter as a Integer. I need to change some values in the supplied structure but cannot work out how to do this - any ideas?
|
|
|
|
|
I', developing mind mapping sofware and need for my user to be able to draw arrows. Using Vis basic.net v2002 - how the hell can i do this?, the help file code throws errors !!! hair is now being lost as deadlines loom !!!
|
|
|
|
|
with a more specific and precise question we may provide you a better answer.
Anyway the route to follow is the following:
1) Decide where do you want to draw
(i.e. a form called myForm)
2) Get the graphic enviroment
(with a myG=myForm.CreateGraphic)
3) Create and define a Pen with an arrow style:
(dim mp as new Pen(Black)
mp.endcap=ArrowAnchor)
4) Draw the line with the correct pen
(myG.DrawLine(mp,start,end))
where start and end are the coordinates.
Of course you need to provide the correct namespaces (i.e. for the ArrowAnchor) or simply import them in the beginning.
|
|
|
|
|
Thanks for your help there chap... I'd got to this route myself, now having a problem resizing said arrow heads, they seem to be connected to the width via ratio. is 'customendcaps' the way forwards ?
|
|
|
|
|
Well with the pre-format caps your stuck with them, and by changing the line width you affect the cap, an arrow in this case, as well.
Yes one good way would be to go with the "Custom" caps.
You create a CustomLineCap. This object has a BaseCap (set it to AnchorArrow) that can be a predefined LineCap. Then you can play with the WidthScale property that realates cap dimension with the pen dimension.
Have a couple of tries and see how it works.
|
|
|
|
|
GOT IT !!
Many thanks for your help, not a wasted day after all!!!
|
|
|
|
|
i want to save the font settings of the fontdialog into xml file , there is a problem to save info of fontstyle which are italics, bold, italics bold these properties! (caution: these values can be saved only as string or integer)
I am Entry level person
|
|
|
|
|
All,
I could use some feedback related to sending emails in .NET (vb).
The functionality must include the ability for the client (standalone pcs on various internet connections and ISPs) to send emails containing data from the application. There are many ways this can be done.
1. Launching outlook express and use the clients own smpt server.
2 Use the system.web.mail namespace (I have alread build a component for this) and send email through a dedicated smtp (or configurable to use clients own settings).
3. Build a Webservice that clients can use for sending emails...
If anyone has any experience from this kind of considerations it would be very interesting to take part of, or if anyone has used or seen a similar solution. Another consideration is the trouble it would cause if the too much work and config is left to the clients such as setting up their smtp server (bullet 2). Authorization on server is another consideration that applies for bullet 2 when using POP3 (smtp normaly does not req auth)... as you see I have many questions and angles on this
Any input is welcome! Thanks in advance! /A
|
|
|
|
|
I developed a program that sends emails directly to a smtp server. I do not rely on Outlook or any other client. I also avoided the webservices route. Read this article! http://www.faqs.org/rfcs/rfc821.html[^]
|
|
|
|
|
I have looked into it but can't really see how to get started. E.g does the program require any additional dlls? Is there samples somewhere?
thanks /A
|
|
|
|
|
Dear sirs
please help me how can i deplay an vb.net application with sql server database .i am new in sql server
hi,this is from D.paranthaman india
|
|
|
|