|
In VFP, Each control added to the form has a Init Method, where this is the first Method to be executed when the form runs.
Suppose I want to add A combo, and add 3 item to it.
I tried to search for method in vb and could not find it, so the only place I found to put my code for a form control is in the Form_Load()
Is there a method belong to the control so I can put my initial code in or just in Form_Load() ?
TIA
Like car accidents, most hardware problems are due to driver error.
Samir R. Ibrahim
|
|
|
|
|
When the code behined is generated there is a method like public partial class formname in that method will be something like InitializeComponent(); put your initialisation after that. Or in the form load.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
Further to my recent post.....does anyone have a working .net Server Control (code) for Virtual Earth that I can use? I want to see how other programmers create Server Controls. Most of what I've done is through trial and error
|
|
|
|
|
Ask in the ASP.NET Forum.
|
|
|
|
|
Public Declare Function ExtFloodFill Lib "gdi32" Alias "ExtFloodFill" (ByVal hdc As Integer, ByVal x As Integer, ByVal y As Integer, ByVal crColor As Integer, ByVal wFillType As Integer) As Integer
I want above API use with VB.NET. But I can't found hdc property in Picturebox control.
Any body tell me how to use this function.
|
|
|
|
|
Take a look at this[^], and see if you can work out how to apply it to a PictureBox.
BTW, unless you absolutely have to, avoid PictureBox. It is only good for displaying a picture that you will never, and I mean never, interact with.
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.”
|
|
|
|
|
Hi ,
PictureBox1.Handle is how you get the handel (hdc)
you will require to change the declaration a bit , the new declaration of the API
should be as following
Public Declare Function ExtFloodFill Lib "gdi32" Alias "ExtFloodFill"
(ByVal hdc As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal
crColor As Integer, ByVal wFillType As Integer) As Integer
Hope this helps
Let me know if you need further help
-Regards
Bharat Jain
bharat.jain.nagpur@gmail.com
|
|
|
|
|
Hi,
I think I got this ASP.NET Server Control code from here. It works in Firefox but not in IE. Does anyone know why?
ASP.net 2.0
Language - VB
Site Content Manager – Dot Net Nuke
VB Code:
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.ComponentModel
Imports System.Collections
Public Class MapControl
Inherits WebControl
#Region "Variables"
Private _dataSource As IEnumerable
Private _VarMap As String = "var map = null;"
Private _GetMapOpen As String = "function GetMap(){"
Private _CloseBracket As String = "}"
Private _LoadMap As String = "map.LoadMap();"
Private _PinId1 As String = "var pinid1=0;"
Private _Locs1Array As String = "var locs1 = new Array;"
Private _MapAddPushpin As String = "map.AddPushpin(pin);"
Private _IncrementPinId As String = "pinid1++;"
Private _Latitude As String = "47.6"
Private _Longitude As String = "-122.33"
Private _ZoomLevel As Integer = 10
#End Region
#Region "Properties"
Public Property DataSource() As IEnumerable
Get
Return _dataSource
End Get
Set(ByVal value As IEnumerable)
_dataSource = value
End Set
End Property
<Browsable(True), Category("Position")> _
Public Property Latitude() As String
Get
Return _Latitude
End Get
Set(ByVal value As String)
_Latitude = value
End Set
End Property
<Browsable(True), Category("Position")> _
Public Property Longitude() As String
Get
Return _Longitude
End Get
Set(ByVal value As String)
_Longitude = value
End Set
End Property
<Browsable(True), Category("Position")> _
Public Property ZoomLevel() As Integer
Get
Return _ZoomLevel
End Get
Set(ByVal value As Integer)
_ZoomLevel = value
End Set
End Property
#End Region
#Region "String Functions"
Private Function NewNamedMap(ByVal MapName As String) As String
Return "map = new VEMap('" & MapName & "');"
End Function
Private Function NewLocation(ByVal longatude As String, ByVal latitude As String) As String
Return "var loc = new VELatLong(" & longatude & "," & latitude & ");"
End Function
Private Function AddPushPin(ByVal Arr As String, ByVal Location As String) As String
Return Arr & ".push(" & Location & ");"
End Function
Private Function ForOpen(ByVal Arr As String) As String
Return "for (i=0; i < " & Arr & ".length; i++){"
End Function
Private Function RunBestMap(ByVal Arr As String) As String
Return "DoBestMap(" & Arr & ");"
End Function
#End Region
#Region "Map Strings"
Private Function MapWithDatasource() As String
Dim str As String = ""
str &= "<script "
str &= "type=""text/javascript"""
str &= ">"
str &= _GetMapOpen & _VarMap & NewNamedMap("MyNewMap") & _LoadMap
str &= _Locs1Array
str &= _PinId1
Dim DataEnum As IEnumerator
DataEnum = DataSource.GetEnumerator()
Dim i As Integer = 0
'str &= ForOpen("locs1")
While (DataEnum.MoveNext())
Dim st1, st2, st3, st4 As String
st1 = DataEnum.Current
DataEnum.MoveNext()
st2 = DataEnum.Current
DataEnum.MoveNext()
st3 = DataEnum.Current
DataEnum.MoveNext()
st4 = DataEnum.Current
str &= NewLocation(st1, st2)
str &= AddPushPin("locs1", "loc")
str &= "var pin = new VEPushpin(" & i.ToString & ", locs1[" & i.ToString & "], null, '" & st3 & "', '" & st4 & "');"
str &= "map.AddPushpin(pin);"
i += 1
End While
'str &= _CloseBracket
str &= "map.SetMapView(locs1);"
str &= _CloseBracket
str &= "</script>"
Return str
End Function
Private Function BasicMap() As String
Dim str As String = ""
str = "<script ""language=""JavaScript"">"
If Latitude <> "" And Longitude <> "" Then
str &= _GetMapOpen & _VarMap & NewNamedMap("MyNewMap") & _
"map.LoadMap(new VELatLong(" & Latitude.ToString & "," & Longitude.ToString & "), " & ZoomLevel.ToString & ",'h' ,false);" & _CloseBracket
Else
str &= _GetMapOpen & _VarMap & NewNamedMap("MyNewMap") & _LoadMap & _CloseBracket
End If
str &= "</script>"
Return str
End Function
#End Region
#Region "Control Methods"
Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)
MyBase.OnPreRender(e)
Dim meta As String = "<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"">"
Dim link As String = "<script type=""text/javascript"" src=""http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2""></script>"
Me.Page.ClientScript.RegisterClientScriptBlock(GetType(String), "Meta", meta)
Me.Page.ClientScript.RegisterClientScriptBlock(GetType(String), "Link", link)
Controls.Add(New LiteralControl("<div id='MyNewMap' style=""position:relative; width:600px; height:300px;""></div>"))
If Not _dataSource Is Nothing Then
Me.Page.ClientScript.RegisterClientScriptBlock(GetType(String), "OnLoad", MapWithDatasource)
Else
Me.Page.ClientScript.RegisterClientScriptBlock(GetType(String), "OnLoad", BasicMap)
End If
End Sub
Protected Overrides Sub OnDataBinding(ByVal e As EventArgs)
Controls.Clear()
End Sub
#End Region
End Class
|
|
|
|
|
Probably do better in the ASP forum.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hi,
i am using multiple tables to create a report since Microsoft report viewer does not allow multiple tables so i have used a stored procedure with parameter. i have refreshed my data set and now my dataset also contains the data table for the stored procedure.the .rdlc also has been successfully linked with the columns and rows of the stored procedure data table. in the form where i am using the report viewer in the load event i have used the table adapter for the stored procedure to fill the stored procedure data table with the values, i am also passing the parameter to the table adapter.
but on doing this i get an error:
Error 1 Value of type 'innoerp.innoerpDataSet1.StoredProcedure2DataTable' cannot be converted to 'innoerp.innoerpDataSet.StoredProcedure2DataTable'. C:\Documents and Settings\prog- 2\My Documents\Visual Studio 2008\Projects\innoerp1\innoerp1\Daily Sales Report.vb 11 47 innoerp1
here innoerp is the name of my database and storedprocedure2 is the storedprocedure
please help!!!!!!!!!!
thanks in advance
|
|
|
|
|
sourav_bhargava wrote: StoredProcedure2DataTable
I have no idea what the method does for you but your problem has NOTHING to do with the report viewer. You probably have a line of code like:
StoredProcedure2DataTable = getTableFromXXXXXXX
Change it to
StoredProcedure2DataTable = (StoredProcedure2DataTable)getTableFromXXXXXXX
I beleive you need to box the second half!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
thanks Mycroft Holmes for the reply.
i think you are right, but i actually am not being able to figure this one out.
here is the code i have used in form load
Imports Microsoft.Reporting.WinForms.ReportDataSource
Public Class DailySalesReport
Private Sub Daily_Sales_Report_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataTable
'TODO: This line of code loads data into the 'innoerpDataSet.salesmen' table. You can move, or remove it, as needed.
Me.SalesmenTableAdapter.Fill(Me.innoerpDataSet.salesmen)
Me.ReportViewer1.LocalReport.DataSources.Clear()
Me.StoredProcedure2TableAdapter1.Fill(InnoerpDataSet1.StoredProcedure2, ComboBox1.Text)
Me.ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("dt", dt))
Me.ReportViewer1.RefreshReport()
End Sub
End Class
this is giving the error i have earlier mentioned.
|
|
|
|
|
Going to be difficult, I never work with the tableadapters, horrible things they are. What type does Me.StoredProcedure2TableAdapter1.Fill expect as it's forst parameter. Presumably salesman fills Ok so what are the differences between the 2 methods!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
fill wants data table of as the first parameter
|
|
|
|
|
thank you every one the problem has been resolved .
i just created another dataset specially to keep the data table values and then filled the table adapter and then refreshed the report viewer this solved the problem.
|
|
|
|
|
hello every one
i want to add columns in checklisbiox like listview so that i can make the width of column to zero which will be not visible to end user is there any code in .net which is helpful to me. in vb i had used checklistbox for the same and it worked but in .net the same is not working.
please suggest what to do..
thank u in advance..
|
|
|
|
|
I'm using instructions from Bob Powell's website [^] to save an edited image back to its original file name. Here's my problem:
This is a batch operation with multiple images receiving the same changes. Often, I'll get the GDI+ generic error caused when the original image in memory has not been disposed. The new image to be written back to the original is created one line before disposing of the original (locked) bitmap:
newImg = CreateNewImage(tmpBMP, newW, newH) 'created in function elsewhere in app
tmpBMP.Dispose()
'Following the above code is the code that sets the format and saves the image
The error does not occur if I do the following instead:
newImg = CreateNewImage(tmpBMP, newW, newH)
tmpBMP.Dispose()
If tmpBMP.Equals(Nothing) Then
MsgBox("NOTHING")
End If
'Following the above code is the code that sets the format and saves the image
The graphics object used to draw the new image in memory is disposed in the called function.
Am I correct in assuming that my app isn't getting enough time to dispose of the original before trying to write back to it? The msgbox NEVER actually opens either way, which also confuses me (I'm a newbie to GDI+).
If I do need to be sure the app has enough time to dispose of the original, what is a good way to create the necessary delay? Any suggestions appreciated.
AB
|
|
|
|
|
Dispose() does not set the object to Nothing, you need to do that yourself. I am guessing the extra code creates time for something to happen in the framework. Ultimately, you're struggling against a bug in .NET, I believe if you change the way you load your image, you can get around this.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Christian Graus wrote: I am guessing the extra code creates time for something to happen in the framework
Thanks Christian.
I moved the dispose() statement to the function that creates the new image. That seems to have solved the problem. If worse come to worse, I can probably drop a timer into the code somewhere.
|
|
|
|
|
Hey,
I am trying to print an overview with a For Each loop. Now, in this loop I check whether the current Y position exceeds the pages maximum Y, and if so, I set e.HasMorePages to True . However, this isn't working. It keeps printing and printing while it shouldn't. Here is an example of my code. (In the PrintDocument.PrintPage Event)
For Each Uitgave As Xml.XmlNode In UitgavenNode.ChildNodes(MonthToPrint).ChildNodes
...
StartY+=PrintFont.GetHeight
If StartY >= e.MarginBounds.Height Then
StartY = e.MarginBounds.Y
e.HasMorePages = True
Else
e.HasMorePages = False
End If
Next
So the bottom line is: When StartY >= e.MarginBounds.Height then it must jump to a blank page and continue printing. Please note that this all happens within a loop and printing must continue at the same position within the loop.
Please tell me what's wrong with this code, so I can fix it
Thanks in advance,
Zaegra
Motivation is the key to software development.
|
|
|
|
|
The PrintPage event is fired for each and every page that gets printed. Your code sample is a bit incomplete, but it looks like you're printing the same thing on every page. Are you printing only what fits on a page, saying the point in the loop that you're at and restarting the loop at the point you saved in the previous handling of the PrintPage event.
|
|
|
|
|
Hi there, I'm trying to migrate an existing vb6 mail application to vb 2008 but it fails conversion. Anyway I'm looking for a module to send email with attachments using outlook 2003. Code must be written in vb 2008. What I can't get is attaching a document to the email! What I have so far is:
Module Module1
Dim app As Object
Dim itm As Object
Dim myItem As Object
Dim myAttachments As Object
Sub sendmail()
app = CreateObject("Outlook.Application")
itm = app.CreateItem(0)
With itm
.To = "someone@yahoo.com"
.CC = "someone@hotmail.com"
.Subject = "test"
'.importance = "high"
'.BodyFormat = Microsoft.Office.Interop.OutlookolFormatHTML
.Body = "Test message"
.send()
End With
MsgBox("message sent", vbOKOnly, "sent....")
End Sub
End Module
All I do is call the sendmail() function from a cmd button! There are other example send mail applications out there but they are written in vb.net and uses smtp(which I don't need)
|
|
|
|
|
I'm pretty sure that itm should have an attachment property.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I hope it did, but vb2008 is different from vb6 (which had the attachment property).
|
|
|
|
|
It doesn't matter. The object you're using are not exposed by VB6 or VB.NET. They are exposed by the COM-based classes you are creating instances of. The properties would be identical.
|
|
|
|