|
Is this a case where you want to have like a list of orders and want to open the specific order on a seperate form when you doubleclick the row on the datagridview or something like that?
|
|
|
|
|
Yes. That is exactly correct.
|
|
|
|
|
OK....I have just been doing the exact same thing and have it working great. Here is what you need to do:
1) Declare a public parameter as integer on the MDIParent form called something like OrderID or whatever
2) on the doubleclick event on the datagridview you need to:
-Get the correct orderID from the datagridview by specifying the correct index (column) value on the currentrow.
-Set the orderID parameter = ID found on the datagridview
3) on your table adapter that is called on the load event on the new form you need to pick up the MDIParent.OrderID in a parameterized fill query.
Let me know if you need some example syntax?
Let me know and I'll post some.
|
|
|
|
|
That's great... Could you please post some sample code? I have declared my variable, but it is not passing the id to the other form when I double click on the datagridview row...
Thanks for your assistance!
-- modified at 12:50 Thursday 10th May, 2007
|
|
|
|
|
Just to clarify....by MDIParent I mean the MDI frame form. I have found that is a stable base to place parameters that need to be shared between forms.
here is a syntax example
Private Sub CustSalesOpportunityDataGridView_CellDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles CustSalesOpportunityDataGridView.CellDoubleClick<br />
<br />
<br />
MDIParent1.SalesOppToOpen = Me.CustSalesOpportunityDataGridView.Item(0, CustSalesOpportunityDataGridView.CurrentRow.Index).Value<br />
<br />
Dim SalesOpportunity As New NewSalesOpportunity()<br />
SalesOpportunity.Show()<br />
End Sub
This should work for you too
|
|
|
|
|
somebody tell me please how to shutdown the system from Visual Basic.NET Windows Application.
I need the code which allow me to do that ..
Actually I'v tried to do it by declaring for an API function and write ExitWindowsEx(....) but it works only for Log Off the system. 'EWX_SHUTDOWN' doesn’t work at all.
thanks for help
|
|
|
|
|
So lets see your code. We'll help you fix yours. We won't write your code for you.
|
|
|
|
|
'In general section
Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Integer, ByVal dwReserved As Integer) As Integer
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ExitWindowsEx(EWX_FORCE Or EWX_SHUTDOWN, 0)
End Sub
'' Thanks in advance
|
|
|
|
|
OK. You really need to read the documentation on ExitWindowsEx[^]. If you use 0 for the second parameter, you can delay system shutdown considerably because this tells Windows that this is more-or-less an unplanned shutdown and XP and above will treat it like a crash. The ShutdownReason parameter is there for a reason, use it.
Also, if any application says that it's not OK to shutdown, it can abort the shutdown.
Your ignoring the return code. If this the return code is 0, then an error occured and you'll have to call the Win32 API function GetLastError to figure out why the call failed.
And last, but not least, you need to request the SE_SHUTDOWN_NAME privilege before you call ExitWindowsEx. You can find out how to do this by following the link on the ExitWindowsEx page for AdjustTokenPrivileges.
|
|
|
|
|
Hi
Is there a SIMPLE way to play MP3 and Midi files from within an application - Is there a class that can access media player or something?
What I want to be able to do is to Play, Stop, Adjust Master Volume, and perhaps have a Slider that I can drag to a position in a song.
I found some stuff in C#, but I need it in VB.Net.
I'm using VS2005
|
|
|
|
|
It's easy enough to translate C# to VB.NET. The two languages have far more in common than it would appear.
What's the C# code you have?
|
|
|
|
|
|
'----------------------------- كنترل هاي مورد استفاده
'-------------PageSetupDialog
'-------------PrintDocument
'-------------PrintPreviewDialog
'--------------------------------------------------------------
Private Sub MnItmPRINT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnItmPRINT.Click
If -DataSet-Name- .Rows.Count > 0 Then
CountLine = 0
NumberColumnsForPrint = -DataSet-Name- .Columns.Count
Titr = " جدول ..."
'-در اين صفحه متغيير هاي سراسري را كاربر تنظيم مي كند
'-مانند تعداد ستونها يا نوع خط جدول و ...
Dim OBJ As New PrintSettingPAGE()
OBJ.ShowDialog()
PageSetupDialog1.ShowDialog()
PrintPreviewDialog1.ShowDialog()
Else
MsgBox("اطلاعاتي براي پرينت وجود ندارد", MsgBoxStyle.OKOnly, "")
End If
End Sub
'------------------------------------------------------------------
'----------------------------- توابع مورد نياز پرينت ---------------
'------------------------------------------------------------------- Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
'----------------------------- متغير هاي سراسري استفاده شده-------------'-------------dim VerticalPAGE as Boolean افقي يا عمودي بودن صفحه
'-------------dim NumberColumnsForPrint as integer
'--------DirectionVertical تعداد ستونهاي ديتاست كه ميخواهيم چاپ كنيم
'-------------dim LinesPerPage as Integer تعداد خطهاي هر صفحه
'-------------dim Titr as String تيتر هر صفحه
'-------------------------------------------------------------- '''''''''''''''''''''''''''''''''''''''''
AxProgressBar2.Visible = True
AxProgressBar2.Value = 1
''''''''''''''''''''''''''''''''''''''''
Dim xCell As Integer
Dim yCell As Integer
Dim WidthCell As Integer
Dim xTITR As Integer
Dim yTITR As Integer
Dim HeightTITR As Integer
Dim WidthTITR As Integer
'--------------------------------------------------------------
'------------مقدار دهي اندازه ها و موقعيت سلول هاي جدول
'--------------------------------------------------------------
yTITR = CInt(PageSetupDialog1.PageSettings.Margins.Top)
xTITR = CInt(PageSetupDialog1.PageSettings.Margins.Left)
If PageSetupDialog1.PageSettings.Landscape = True Then
WidthTITR = CInt(PageSetupDialog1.PageSettings.PaperSize.Height) - (xTITR + CInt(PageSetupDialog1.PageSettings.Margins.Right))
Else
WidthTITR = CInt(PageSetupDialog1.PageSettings.PaperSize.Width) - (xTITR + CInt(PageSetupDialog1.PageSettings.Margins.Right))
End If
HeightTITR = 35
xCell = PageSetupDialog1.PageSettings.Margins.Left
yCell = yTITR + HeightTITR
WidthCell = CInt(WidthTITR \ NumberColumnsForPrint)
'--------------------------------------------------------------
'------------محاسبه تعداد خطهاي هر صفحه
Dim LinesPerPage As Integer
If PageSetupDialog1.PageSettings.Landscape = True Then
LinesPerPage = CInt((CInt(PageSetupDialog1.PageSettings.PaperSize.Width) - (yTITR + HeightTITR + HeightHeaderCell + CInt(PageSetupDialog1.PageSettings.Margins.Bottom))) \ HeightCell)
Else
LinesPerPage = CInt((CInt(PageSetupDialog1.PageSettings.PaperSize.Height) - (yTITR + HeightTITR + HeightHeaderCell + CInt(PageSetupDialog1.PageSettings.Margins.Bottom))) \ HeightCell)
End If
'---------------------------------------------------------------------- Dim RectF As RectangleF
If -DataSet-Name- .Rows.Count <> 0 Then
'----------------------------------------------------------
'------------ نوشتن متن تيتر
'---------------------------------------------------------- Dim StrForm As StringFormat
StrForm = New StringFormat(StringFormatFlags.DirectionRightToLeft)
StrForm.Alignment = StringAlignment.Center
StrForm.LineAlignment = StringAlignment.Center
RectF.X = xTITR ' xTITR = 15 or 790
RectF.Y = yTITR ' yTITR = 15 or 15
RectF.Height = HeightTITR ' HeightTITR = 25 or 25
RectF.Width = WidthTITR ' WidthTITR = 750 or 1140
e.Graphics.DrawString(Titr, TitrFont, Brushes.Black, RectF, StrForm)
'----------------------------------------------------------
'------------ نوشتن سطرها
'---------------------------------------------------------- RectF.X = xCell
RectF.Y = yCell + HeightHeaderCell
RectF.Width = WidthCell
RectF.Height = HeightCell
StrForm.Alignment = StringAlignment.Far
StrForm.LineAlignment = StringAlignment.Far
Dim PrintFont As New Font("Arial", 10)
PrintFont = DataGrid1.Font
Dim StrField As String '' براي دريافت فيلدهاي جدول
Dim counter As Integer '' شمارهنده
For I2 = 0 To LinesPerPage - 1
RectF.X = xCell
For I = (NumberColumnsForPrint - 1) To 0 Step -1
StrField = " " & CStr( -DataSet-Name- .Rows(CountLine).Item(I))
e.Graphics.DrawRectangle(PenRow, RectF.X, RectF.Y, RectF.Width, RectF.Height)
e.Graphics.DrawString(StrField, PrintFont, Brushes.Black, RectF, StrForm)
RectF.X += WidthCell
StrField = ""
Next
RectF.Y += HeightCell
CountLine += 1
If -DataSet-Name- .Rows.Count = CountLine Then
Exit For
End If
Next
'----------------------------------------------------------
'------------ كشيدن نام ستونها فقط 12 ستون
'---------------------------------------------------------- StrForm.Alignment = StringAlignment.Center
StrForm.LineAlignment = StringAlignment.Center
RectF.X = xCell
RectF.Y = yCell
RectF.Width = WidthCell
RectF.Height = HeightHeaderCell
PrintFont = DataGrid1.HeaderFont
For I = (NumberColumnsForPrint - 1) To 0 Step -1
StrField = CStr( -DataSet-Name- .Columns(I).ColumnName)
e.Graphics.DrawRectangle(PenColumn, RectF.X, RectF.Y, RectF.Width, RectF.Height)
e.Graphics.DrawString(StrField, PrintFont, Brushes.Black, RectF, StrForm)
RectF.X += WidthCell
StrField = ""
Next
End If
'--------------------------------------------------------------
'------------اگر تعداد خطها زياد شد بايد صفحه ديگر ايجاد شود
'------------در غير اين صورت صفحه جديد نبايد توليد شود
'-------------------------------------------------------------- If CountLine < -DataSet-Name- .Rows.Count Then
e.HasMorePages = True
Else
CountLine = 0
e.HasMorePages = False
End If
End Sub
|
|
|
|
|
Would you like to ask a particular question about this stuff??
Or do you normally just go around to forums and post random, yet long, sections of code for no particular reason?
|
|
|
|
|
Hey Guys, this I need to do hopefully you guys can help.
I just need an application or service to browse to a certain page every five minutes. In my case it will be an asp page. Once the services browses to the page it just needs to close the and the asp page takes it from there and starts producing a grid. For instance when it connects properly the grid will show some green, but say the service gets stopped or the computer or server goes down then the grid will start showing red.
I hope that all made sense, if not just let me know and i will try to give some more info. I am just hoping someone can help.
Thanks, Travis
|
|
|
|
|
You can use WebRequest class in System.Net to browse a web page. Pass a querystring that is unique to your calling application. When you execute WebRequest.GetResponse(), you can be sure that the application is trying to connect to the web page.
In the ASP page, check from the querystring if the connection request is from your calling application, if yes, do your color thing.
SG
|
|
|
|
|
Hey man,
I just wanted to say thanks alot for that little bit of information. By using the webrequest I got the results I was needing.
Thanks again,
Travis
|
|
|
|
|
if any one has the code that connect visual basic 6 with sql server 2000
plzz send me on my id jawad1_hassan1@hotmail.com
plzzz
|
|
|
|
|
I've got much better idea: Write it yourself.
When you get stuck at a certain point, then you can ask questions about the problem you're having. BTW, there is no "just do this" code that you can use to "connect" to an SQL, or any database, server. How you retrieve data from a database depends on what you want to do with the data and how the database is organized and even how your code is organized. There's lots of different ways to do this.
|
|
|
|
|
how to insert or save the entering values into msaccess from vb.net windows application?
|
|
|
|
|
http://www.google.com.au/search?hl=en&q=insert+save+access+vb.net&btnG=Search&meta=[^]
I trimmed a few words from your original question, but even the full question gave useful hits in google. We really can't offer anything more specific without knowing about your database, and you should read the generic stuff first.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
how to insert or save the entering values into msaccess from vb.net windows application?
|
|
|
|
|
if any one has the code that connect visual basic 6 with sql server 2000
plzz send me on my id jawad1_hassan1@hotmail.com
plzzz
|
|
|
|
|
how to insert or save the entering values into msaccess from vb.net windows application?
|
|
|
|
|
A simple google search[^] provides you with a lot of information.
Have a look at this article[^]
Do not spam the forums, delete your other duplicate messages.
|
|
|
|