|
I have produced a grid from 2 tables that has been formated and displays about 100 rows of information (Each row has 30 cols). I would like to be able to print the grid. Has anyone any ideas how to do this or to point me in the right direction.
Thanks in advance.
Peter
|
|
|
|
|
This[^] little example on MSDN might get you started.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Mny tks for the help - will try it.
|
|
|
|
|
Try this
Dim ActivePageNumber As Short = 1<br />
Dim pageCount As Short = 0<br />
Dim ItemCountOnPerPage As Integer = 30<br />
Dim dtSource As DataTable<br />
Dim index As Short<br />
Private Sub btnPrintDataGrid_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrintDataGrid.Click<br />
ActivePageNumber = 1<br />
pageCount = Math.Ceiling(dtSource.Rows.Count / ItemCountOnPerPage)<br />
PrintDocument1.Print()<br />
End Sub<br />
<br />
<br />
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage<br />
If Not ActivePageNumber > pageCount Then<br />
PrintDataTable(e.Graphics)<br />
ActivePageNumber += 1<br />
e.HasMorePages = True<br />
Else<br />
e.HasMorePages = False<br />
End If<br />
End Sub<br />
<br />
Public Sub PrintDataTable(ByVal e As Graphics)<br />
Dim x, y As Short<br />
Dim fArial As New Font("Arial", 8)<br />
x = 20<br />
y = 20<br />
Dim cci As Short = index<br />
Do While (cci <> ItemCountOnPerPage Or index <> dtSource.Rows.Count - 1)<br />
For columnIndex As Short = 0 To dtSource.Columns.Count - 1<br />
e.DrawString(dtSource.Rows(index)(columnIndex), fArial, New SolidBrush(Color.Black), x, y)<br />
x += 30 ' set this to column width<br />
Next<br />
y += fArial.Height<br />
cci += 1<br />
index += 1<br />
Loop<br />
End Sub
|
|
|
|
|
Mny tks - will try it out.
Peter
|
|
|
|
|
A rather tricky question: Is is possible to design a program to lay on top of two other programs in order to be able to control the audio from these 2 programs. I want to be able to mute the first programs audio so that the other can use the speaker, and the unmute so that the first program uses the speaker. Does anyone know if this is possible? If so, could someone provide me with sample code for VB.net?
Best regards
Mikkel
|
|
|
|
|
No, you can't, for various reasons that depends entirely on the resources and devices your applications are using. You can't control the audio output of those two applications.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi guys
here's my matter:
I want to select (highlight) a word in any application and when I click the right mouse button, I dont want the popup menu to renders, I want to set my own function here, how can I prevent the menu, I saw lots of code on how to disable it in a text box, but here, I want it in general, whenever the right button is clicked...
Anyone can help please.
|
|
|
|
|
You want to disable context menus system-wide? And replace them with your own incarnation of whatever? What are you planning on attempting?
BTW: IMHO it's a very bad idea to do this.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i am trying to add key in the app.config file programitically i am able to read the key through this ReadConfigFile.AppSettings("ConnectionString"), but if i want to add a key during runtime how can i do that.
|
|
|
|
|
Since the app.config file is an XML file, I would probably start with XmlTextReader to load the file and use whatever XML document methods you need to accomplish your goal.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have written a class in C++ and would like to define it as a variable data type in VB. How should I go about it??
|
|
|
|
|
Chances are you're going to do a little rewriting of your class. But your question would be better handled in the Visual C++ forum as I THINK(!) your going to be exposing it to COM so VB can see and use it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am attempting to write a program that will list the running processes on a computer. I currently have a listView box that stores the running processis as items in the ListView. The ListView must update every so often (2 secons or so).
But when it updates it must check to see if a process is already contained in the list. For example there are usually four or so processes with the name svchot.exe, so we must make sure that we also check the PID (a subitem for each item that stores the "Process ID").
My problem is that when I attempt to check if an item is in the listView, it is not found. Here is the coded snipet in question.
'Takes three parameters: lvw is the ListView that contains all of the items,
'item_title is the name of the item we want to add (process name),
'subitem_titles() is an array of strings containing the subitems (PID, CPU time...) Private Sub ListViewMakeRow(ByVal lvw As ListView, ByVal ProcessName As String,_ ByVal ParamArray subitem_titles() As String)
'Temporary ListViewItem used to create a lvw
Dim ListItemTemp As New ListViewItem(ProcessName)
'check to see if our TempListItem is found in lvw
'At least that is what it is supposed to do.
If Not (lvw.Items.Contains(TempListItem)) Then
Dim new_item As ListViewItem = lvw.Items.Add(ProcessName)
For i As Integer = subitem_titles.GetLowerBound(0) To _
subitem_titles.GetUpperBound(0)
new_item.SubItems.Add(subitem_titles(i))
Next i
Else
End If
End Sub
At the moment I am only trying to see if I can check to see if the item is already in the ListView. Later on I will add more checks to see if it is a different process.
Currently the process will continue to add more items to the list even if the item is found in the list. I am not able to debug it to see which items are already in the list and to see if it is making the correct decision. However I know that it does not work because every half a second or so another item with the same name is added to the list (every second a process named “explorer.exe” is added… and so on for each process that runs.
So the question is can anyone point me to a good tutorial on the:
ListView.ListViewItemCollection.Contains
or to some other way of checking the ListView. I have looked at microsofts inof for the ListView class
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformslistviewitemlistviewsubitemclasstopic.asp
however their example does not use the Contains method.
I will attempt to use GetIndexOf. However I am not sure how that would work if there are multiple items with the same name.
Thanks in Advance
Donald Carlson, Jr.
|
|
|
|
|
Unfortunately it is a bit ineficent and lacks the update capabilities, however it does properly check to see if an item with the same name exists and also checks to see if an item with the same subitem exists (assuming there are more then one item with the same name). IF you have any improvements or other ideas pleas feel free to post them.
Private Sub ListViewMakeRow(ByVal lvw As ListView, ByVal ProcessName As String, ByVal ParamArray subitem_titles() As String)
'Creates a temporary listViewItem
Dim CurrentListItem As ListViewItem
'check to see if our TempListItem is found in lvw
If (lvw.Items.Count = 0) Then
'there are no entries in the list (list is empty)
Dim new_item As ListViewItem = lvw.Items.Add(ProcessName)
For i As Integer = subitem_titles.GetLowerBound(0) To _
subitem_titles.GetUpperBound(0)
new_item.SubItems.Add(subitem_titles(i))
Next i
Else
'Well apparently the list is not empty
Dim dataListEnumerator As IEnumerator = lvw.Items.GetEnumerator()
Dim containsItem As Boolean = False
Dim PID As String
'check all entries in the list
While (dataListEnumerator.MoveNext())
CurrentListItem = CType(dataListEnumerator.Current, ListViewItem)
' Display the current DataListItem onto the label.
If (ProcessName = CurrentListItem.Text) Then
containsItem = True
'Stores the PID for later checking if needed
PID = PID & " " & CurrentListItem.SubItems.Item(1).Text
End If
End While
If (containsItem = False) Then
'this process is not found in the list
Dim new_item As ListViewItem = lvw.Items.Add(ProcessName)
For i As Integer = subitem_titles.GetLowerBound(0) To _
subitem_titles.GetUpperBound(0)
new_item.SubItems.Add(subitem_titles(i))
Next i
Label2.Text = "sweet unnion rings"
ElseIf (PID.IndexOf(subitem_titles(0)) = -1) Then
'this specific process with this specific PID is not found
'Assumes that contansItem is true
Dim new_item As ListViewItem = lvw.Items.Add(ProcessName)
For i As Integer = subitem_titles.GetLowerBound(0) To _
subitem_titles.GetUpperBound(0)
new_item.SubItems.Add(subitem_titles(i))
Next i
End If
End If
End Sub
Donald Carlson, Jr.
|
|
|
|
|
Hi all
I am trying to convert a html page (home.htm) to an asp page (home.aspx). Please can anyone show me how to work this out?
Thanks very much for help!
|
|
|
|
|
Well, that depends on what you want to do. The best thing would be to copy and paste your page into the aspx, between the form tags, then go through and replace all controls with aspx controls. The easy way is to keep the old html controls, but then why would you convert to aspx anyhow ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Thanks for help, Christian!
|
|
|
|
|
Howdy.
I have a program with 4 different listviews.
I have also created a context menu that contains tasks that should be possible to perform in the different listviews.
In the four different listviews the exact same tasks should be performed so I need only one context menu, but how do I know which listview the call comes from when the context menu is activated?
I.E:
Private Sub listView_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseUp, ListView2.MouseUp, ListView3.MouseUp, ListView4.MouseUp
' Checking the Mouse right Button
If e.Button = MouseButtons.Right Then
Dim myLV As ListView = sender
myLV.ContextMenu.Show(sender, New Point(e.X, e.Y))
End If
End Sub
and then:
Private Sub MenuItem17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem17.Click
listview_that_the_menu_was_started_in.Items.Clear()
End Sub
How do solve?
Thanks for assistance.
Anders Liden
Gothenburg, Sweden.
|
|
|
|
|
Hi to ALL,
Can anybody help me in telling the difference between the CreateObject function and New method
Thanks to ALL
|
|
|
|
|
CreateObject requires a COM typeID ( from memory, I'm sure it's not a GUID ), and spins up a COM object. new just creates an object within your code.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Hello,
In this Web site the following article was published: "Hacking the Combo Box to give it horizontal scrolling By Tomas Brennan".
It is possible to do using it VB 6.0?
Thanks.
This is the direction of the article: http://www.codeproject.com/cs/combobox/ComboHack.asp
|
|
|
|
|
|
Hi,
I have been banging my head on a wall with this one. I'm trying to open a form from that I know the name of. This is not as easy as it might first sound.
This is the normal way of opening a form:
dim formCustomers as new frmCustomers<br />
formCustomers.Show()
That is easy! But what I want is something like this:
dim formName as String ' This is the name of an actual form that exists<br />
dim newForm as Form<br />
<br />
newForm.Name = formName<br />
newForm.Show
If I set newForm = new Form then this opens a form, but not the form that I want to open! It opens up a completly new form.
Can anyone help me here?
I am puzzled
Thanks
Shawn
|
|
|
|
|
My first question would be, why are you passing a form name? Where is this comming from and why can't this code just create the form object itself?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|