|
Source = Image.FromFile("c\test")
Dim imag As New Bitmap(width, height) 'size of the portions you want
Dim rc As New Rectangle(x, y, width, height) 'location from where to take the portions
Dim gr As Graphics = Graphics.FromImage(imag) 'graphics to do the extraction
gr.DrawImage(Source, 0, 0, rc, GraphicsUnit.Pixel) 'the extraction from the source image
Dim ResultImg as Bitmap = new Bitmap(imag) ' the resulting image
It would not be too diffucult to base this process around mouse actions. width would be one third of the images total width, height would be the height of the image. The source image does not have to be from a file, it just was in my original app.
|
|
|
|
|
Some one beat me to the answer. I'd recommend you both buy a good book to give you access to this sort of information, and learn how to negotiate google and the MSDN site, because you're always going to want to be finding out how APIs work, it's good to be able to find that info for yourself.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I am working on a project where I am showing data In datagrid by binding this with datatable.I am using a listview as well.Now what I want is that if user select single or multiple rows from the grid and click on add button then the selected rows should be added In the listview.
For single row this can be done but don't know how to do for multiple rows.
Any idea how to solve this?
Thanks in advance
|
|
|
|
|
hi ,
use following statement
for i as integer =0 to datagridview1.SelectedRows.count-1
'your code appear here
next
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
Thanks for the reply but I am using datagrid not datagridview and there is no selectedrows property for datagrid in vb.net 2003.
|
|
|
|
|
What condition should appear in the for..next loop to get the selected rows?
I tried the following
Dim I as Integer
for i = 0 to datagridview1.SelectedRows.count-1
what code should appear here to get the selected rows.
next
|
|
|
|
|
Problem in Vb.net useing crystel report Load report to fail
i am getting error load report to fail in vb.net windows form project here i pest exception details please help me
System.Exception was unhandled
Message="Load report failed."
Source="CrystalDecisions.CrystalReports.Engine"
StackTrace:
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob)
at CrystalDecisions.CrystalReports.Engine.ReportClass.Load(String reportName, OpenReportMethod openMethod, Int16 parentJob)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.EnsureLoadReport()
at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(DataSet dataSet)
at ACCOUNT.crview.crview_Load(Object sender, EventArgs e) in D:\D.NET\ACCOUNT\ACCOUNT\crview.vb:line 6
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.Show()
at ACCOUNT.MainMenu.CashToolStripMenuItem_Click(Object sender, EventArgs e) in D:\D.NET\ACCOUNT\ACCOUNT\MainMenu.vb:line 121
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at ACCOUNT.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
|
|
|
|
|
Jigneshjpatel wrote: at ACCOUNT.crview.crview_Load(Object sender, EventArgs e) in D:\D.NET\ACCOUNT\ACCOUNT\crview.vb:line 6
What's in crview.vb on line 6? Put a break point before it and step through the code to see what's causing the error (look in local variables for clues).
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
hi all,
can sql is suppport by all os specially mac and linux.
And give me idea about which database is supported by all os (mac/linux/windows).
help me please......
Thank You in advance
Senthil.S
Senthil S
Software Engineer
|
|
|
|
|
SQL is supported everywhere. SQL Server is another matter. MySQL may be supported on Max and Linux, it seems like a products created by the same sort of hippys as Linux.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
thanks,
wat about mac os?
wheather it support mysql??
Senthil S
Software Engineer
|
|
|
|
|
Senthil S wrote: wat about mac os?
wheather it support mysql??
If you are looking for cross platform, MySQL is your best bet. Binary distributions are currently available for Windows, Linux, Solaris, FreeBSD, Mac OS X, HP-UX, IBM AIX and i5 OS, QNX, Novell and SCO:
http://dev.mysql.com/downloads/mysql/5.0.html[^]
OR you can download the source code and compile it on other OS not specified above:
http://dev.mysql.com/downloads/mysql/5.0.html#source[^]
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
Why does control +C and control +V doesn't work on textbox controls of VB.Net 2005 forms when we run them. But Right click -Copy, Paste works fine on the controls.
Could anybody tell what is the reason.
Sekhar
|
|
|
|
|
They do, as far as I know. What makes you think otherwise ? Are these textboxes you've written any event handlers for ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hello every one
I am making an application in VB 2005 Express. Hear I am accessing a remote database.
When the networks is disconnected for some time and is connected back, the application still dose not connects to the DB again until I exit and start again.
On looking at the thing in detail I was able to come down to the following things
- Can we some how refresh the connection
- Can we refresh / flush the port on which DB is connected
If any one has any ideas of how is it done then plz let me know. Also is there any other way of place where I should look in the application
Regards
Nishkarsh
|
|
|
|
|
Are you making the mistake of opening a connection when you app starts and keeping it open for the life of your app??
Or are you opening a connection, doing your database query, then closing the connection?? If this is the case, the problem you're describing can't happen.
|
|
|
|
|
Yes i am opening the connection once only at start and using through out...
My application is based on a DB will it not take a real extra time every time opening and closing the connection???
|
|
|
|
|
nishkarsh_k wrote: Yes i am opening the connection once only at start and using through out...
That's a really bad practice. Holding a connection open for the life of your application also holds onto a very expensive SQL Server license, which are usually bought by the seat. This means that, for example, you can have 10 connection licenses on the SQL Server and about 50 machines using them IF they just open a connection for the time it takes to do a query, then close the connection. Using your method, the same server would have to have 50 licenses, at an addition 4 times the cost of 10.
Your database connection is probably, in a normal situation, idle for 99% of it's life. That's a lot of time holding onto a license and dogint nothing with it.
If a customer using your application caught you doing that, you'd probably be fired on the spot.
nishkarsh_k wrote: My application is based on a DB will it not take a real extra time every time opening and closing the connection???
Nope. The first connection is the most expensive (process wise). Subsequent connections using the same connection string are cached by ADO.NET and open and close very quickly.
modified on Sunday, December 23, 2007 10:32:46 AM
|
|
|
|
|
I have a TreeView loaded with directories/subs/files. I want the ability to click on the file node (most junior node) of this TreeView and transfer the node over to an adjacent ListView control. At this point I want to transfer it either by double clicking on it or simply by putting code in a click event of the ADD button which sits between the the View controls. At this point I am using a basic TreeView without a multiselect option.
How do I transfer individual the most junior node item labels from the TreeView to the ListView? And how do I ensure that the whole file path comes along with it?
Thanks
EM
|
|
|
|
|
First, stop thinking in terms of "transferring". You'll do nothing of the sort.
When you populate the TreeView, you set the Tag property of the TreeViewItem to the full path to the file/folder.
In the button handler code, you get the currently selected item from the treeview, look at it's Tag property to get the full path of the item, then create a new ListViewItem with whatever data you want, making sure to again, put the full path in it's Tag property, add it to the ListView. Then you delete the selected item from the TreeView if you so desire.
|
|
|
|
|
hi all,
i use multi threading in my application which perform the work of downloading file.
the following code Create the thread & start them
<br />
Protected Sub DownloadFileInfo(ByVal sourcePath As String, ByVal DestinationPath As String)<br />
If Not File.Exists(DestinationPath) Then<br />
ReDim Preserve TotalThreads(TotalThreadCreated)<br />
'ReDim Preserve WaitAllDownloadEvent(TotalThreadCreated)<br />
Dim DownLoadObject As DownloadClass = New DownloadClass<br />
TotalThreads(TotalThreadCreated) = New Thread(AddressOf DownLoadObject.StartDownload)<br />
TotalThreads(TotalThreadCreated).Name = TotalThreadCreated.ToString<br />
TotalThreads(TotalThreadCreated).IsBackground = True<br />
'TotalThreads(TotalThreadCreated).<br />
'WaitAllDownloadEvent(TotalThreadCreated) = New AutoResetEvent(False)<br />
<br />
DownLoadObject.DownloadFileWithSourcePath1 = sourcePath<br />
DownLoadObject.DownloadFileWithDestinationPath1 = DestinationPath<br />
DownLoadObject.MyObjectNumber1 = TotalThreadCreated<br />
TotalThreads(TotalThreadCreated).Start()<br />
TotalThreadCreated += 1<br />
<br />
End If<br />
End Sub<br />
<br />
code of downloadClass is following
<br />
Imports system<br />
Imports System.Threading<br />
Imports System.IO<br />
<br />
Public Class DownloadClass<br />
Public DownloadFileWithSourcePath1 As String<br />
Public DownloadFileWithDestinationPath1 As String<br />
Public MyObjectNumber1 As Integer<br />
<br />
<br />
Sub StartDownload()<br />
If Not File.Exists(DownloadFileWithDestinationPath1) Then<br />
Try<br />
<br />
My.Computer.Network.DownloadFile(DownloadFileWithSourcePath1, DownloadFileWithDestinationPath1)<br />
<br />
Catch ex As Exception<br />
End Try<br />
End If<br />
<br />
End Sub<br />
<br />
<br />
End Class<br />
<br />
DownloadFileInfo procedure is called near about 175 times so total 175 thread is created and in Destination folder i can see the icon of all download files(during downloading).
but after some time (near about 2 minute), these 175 icon is decreased and only few icon are appearead (near about 40). I think all thread is died after 2 minute so file attached to these thread is also deleted (note that files is not completely download)
any body have idea where i am wrong ?
any help will be greatly appreciated.
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
Probably because your downloading 175 files all at once. File download operations are probably timing out because of bunch of threads are all waiting on one to use the network pipe. What you're doing is not efficient at all because the network pipe is not really multithread capable. Only one thread can access the network pipe at a time.
Limit your downloads to only a few threads at a time and it should work. Multithreading does NOT make your application faster, nor does it reduce the amount of time it takes to download a group of files. All it does it make your application responsive during a long running operation.
|
|
|
|
|
hello sir,
thanks for your reply.
What you're doing is not efficient at all because the network pipe is not really multithread capable. Only one thread can access the network pipe at a time
Network pipe is not multi threaded capable. Here i want to know one more thing that what is the downloading criteria when i download files on multiple thread. it downloads all files on all thread partially or it first download one file of thread completely and after that it pick other thread file.
size of all files(175) is near about 6 MB. whether it is possible that i successfully download these files using multiple threads. if yes then Please guide me or provide some link or code snippet
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
I thought Dave explained it well enough .. but here goes my shot:
The major choke point in this scenario is the network connection.
High level, ignoring all the details and reality overview:
At heart your network connection is a serial line, pushing one byte at a time to and from your machine.
Those bytes are amalgamated into multiple byte sequences called packets. When a packet arrives at your machine it will be addressed to a logical port number (1-65535). Each of your threads having opened a connection to a remote peer will have a logical port number for that socket connection.
Thus you have 175 open connections, each uniquely addressed, each eagerly awaiting packets from the network connection.
However the first thing I said was that the network connection was serial in nature. Only ONE packet at a time can get through. So for any given moment only ONE thread can receive data. Given that the latency for the network is vastly greater (i.e. slower) then for the core(s) your threads are running on, the OS is happily context switching your threads in and out to do absolutly nothing for most of their lives.
Eventually the network connection (not the threads) time out due to inactivity or failure to tranfer the data - this behaviour is desired and shouldn't be altered unless absolutly necessary.
The best analogy I can think of is a cookie jar with a small opening. One person can reach in and take cookie after cookie. A dozen people reaching in will get their hands stuck and get few if any cookies.
To make a long story short, the optimal number of threads for this operation is : 1
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
Damn, you beat me to it! I was on the road between sites.
Great explanation! That's pretty much what I was going to tell him.
|
|
|
|
|