|
I am redoing some vb6 programs with vb.net. My target system runs 64 bit windows 7 and I.E. 9.0.4
The vb6 program used the command:
l_lngRetVal = ShellExecute(0&, vbNullString, _ txtURL.Text, vbNullString, "C:\", SW_SHOWNORMAL)
To start I.E. and the same command would open additional tabs if I.E. was allready open.
My new program uses the code:
Process.Start("C:\Program Files\Internet Explorer\iexplore.exe", txtURL.Text)
This allways starts a new instance of I.E.
How can I get it to just open a new tab on the existing instance??
|
|
|
|
|
If Internet Explorer is the default browser,
Process.Start(txtURL.Text)
the URL will be opened in Internet Explorer.
I am not sure if it is opened in a new instance, or in a new tab.
|
|
|
|
|
HI,
I need VB code/Macro to fetch QC report? or anyone have query in QC 10 to fetch execution status of tests.
|
|
|
|
|
First, what the $(#*&$ is "QC 10"??
Second, nobody is going write your code for you.
|
|
|
|
|
If you mean Quality Centre, you have my deepest sympathies in having to use that steaming pile. However the DB is just SQL Server, so why not go to that directly?
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
Although in C# this [^] article will act as a good starting point
|
|
|
|
|
Private Sub btnDelete_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnDelete.ItemClick
If Me.NoteSetBindingSource.Current Is Nothing Then
Return
End If
Dim Id As Guid = DirectCast(DirectCast(NoteSetBindingSource.Current, DataRowView)("IdNoteSet"), Guid)
If MessageBox.Show("Delete selected data?", "Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.OK Then
Me.NoteSetAdapter.Delete(DirectCast(DirectCast(Me.NoteSetBindingSource.Current, DataRowView)("IdNoteSet"), Guid))
End If
Me.LoadData(Id)
End Sub
Private Sub btnRefresh_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnRefresh.ItemClick
Me.LoadData()
End Sub
Public Sub LoadData()
Me.LoadData(Nothing)
End Sub
Public Sub LoadData(ByVal Id As System.Nullable(Of Guid))
Me.Dataset.NoteSet.Rows.Clear()
Me.NoteSetAdapter.Fill(Me.Dataset.NoteSet)
If Id.HasValue Then
Me.NoteSetBindingSource.Position = Me.NoteSetBindingSource.Find("IdNoteSet", Id.Value)
End If
End Sub
hi guys, i need help above..
loaddata is used to fill my Grid, but everytime i call it, the bindingsource.position move to first..
nah, if i delete row 3 then my position will stay at row 3.
if 3 is the last row, then the position will move to row 2.
this code doesn't work, can somebody correct it?
|
|
|
|
|
vkstarry wrote: loaddata is used to fill my Grid, but everytime i call it, the bindingsource.position move to first.
That sounds logical, doesn't it? When you (re)load data, the grid cannot "assume" that you're loading the same table in there - so it cannot retain it's position.
vkstarry wrote: nah, if i delete row 3 then my position will stay at row 3.
Either don't reload the grid when you delete an item, or "remember" your index and set it manually;
DataGridView1.CurrentCell = DataGridView1.Rows(1).Cells(0)
Note; this works for the DataGridView that's being shipped with the .NET framework. The DevExpress grid[^] will probably use it's own version of positioning. They've got their own documentation and support-forum which I try to avoid
Bastard Programmer from Hell
|
|
|
|
|
I'm just starting to learn VB 2010 (old VB6 programmer trying to learn new stuff) and I'm having a problem with the DataGridView control.
I've created a datasource to my Access database. It connects to a table in the database. The "Fill,GetData()" tableadapter command produces the appropriate number of rows when I preview the data. However, when I show the form that contains the DGV control no rows are displayed. The form_load event is the default code created by Visual Studio, namely:
Private Sub frmSetAwards_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.JRTableAdapter.Fill(Me.YingexpoDataSet.JR)
end sub
Can anyone suggest what might be the problem?
Thanks
|
|
|
|
|
That is insufficient code to work on. Is it a TableAdapter or a DataAdapter? And where/when/how do you bind it to your DGV? There should be a statement such as myDGV.DataSource = myDataSomething
BTW: I don't use adapters, I tend to fill a DataTable using a DbCommand.Read() loop, than bind the table to the DGV with
myDGV.DataSource = myDataTable
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
Well, the properties of the DGV control shows the DataSource as "JRBindingSource". The JRBindingSource object has as it's DataSource "YingExpoDataSet" The YingexpoDataSet is the datase that I created through the Data Sources wizard.
??
|
|
|
|
|
I've never used the wizard, I tend to write my code myself, that way I know what is and isn't going on.
I do expect you need to keep things in their logical order: first get the data present, then establish the binding; if not, I expect an explicit action would be required (I know removing and re-installing the binding works when the data has changed).
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
As far as I remember you have to attach your DataSet to the DataGridView
dim ds as YingexpoDataset
myDataGridView.DataSource = ds.DefaultViewManager
If you want you can do that with the form designer (top right corner of the DataGridView).
Regards
Mick
|
|
|
|
|
SpareRoom (VBPmanan15)
Find a flatshare or flatmate fast! 1000s of rooms
for rent in flatshares across London, Manchester,
Birmingham, Bristol, Leeds, Edinburgh, Glasgow
and the rest. www.spareroom.co.uk
|
|
|
|
|
We usually "vote to remove" spam around here - I've changed tactics and will be adding each domain to the mvp-hosts and the adblocker-blacklist. The more spammers post here, the less visitors they'll receive.
Have a wonderfull day
Bastard Programmer from Hell
|
|
|
|
|
Hello everybody,
I have a child form which is supposed to show an exact duplicate of a part of the main form including its controls - here I'm in particular speaking about a ComboBox. What I'm trying to accomplish is that the user can either change a setting on the main form's ComboBox or on the child forms ComboBox to have both forms update the underlying list of a Datagridview as well as the ComboBox/Datagridview on the other form.
Is there any 'best practices' way of synchronizing controls on two forms? I would surely have to avoid firing events twice (e.g. combo updated by user would update the corresponding combo on the other form and fire again).
Thanks for advice,
Mick
|
|
|
|
|
AFAIK you can achieve that by using simple data binding:
- create a small class describing each item, with at least two properties (e.g. string Display , and int Value );
- store your items in a generic List;
- for both ComboBoxes set the DataSource to that list, and the DisplayMember and ValueMember to the names of the relevant properties. The DisplayMember is what will be shown, the ValueMember what will be returned as the SelectedValue.
With both ComboBoxes set up identically, they will act like one, i.e. fully synchronized; however each of them will fire its events. So you can deal with each of them as if the other didn't exist.
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
modified 11-Feb-12 8:57am.
|
|
|
|
|
Hi Luc,
sorry for my late response, I had to find the time to figure that out and still find myself stuck.
Following your advice I defined the class "AirportRange"
Public Class AirportRange
Private _display As String
Public Property Display() As String
Get
Return _display
End Get
Set(ByVal value As String)
_display = value
End Set
End Property
Private _value As Integer
Public Property Value() As Integer
Get
Return _value
End Get
Set(ByVal value As Integer)
_value = value
End Set
End Property
End Class Storing the class in a generic list didn't work (e.g. I didn't know how to), so I used the designer and set up the class as a Project DataSource - after which VS creates an "AirportRangesBindingSource" from it. This I used as DataSource for the new comboBoxes on my main and child forms, setting DataMember and ValueMember to the properties as you suggested.
A problem arose: The forms show, but I can't define items for them - which results in no possibility to select any values from the ComboBox. The items obviously have to be defined in the class istself? At least when I open the "items" property, I get an error message saying it wouldn't be possible to set items as a DataSource is defined...
Can you help me out of that?
Thanks for now,
Mick
|
|
|
|
|
You should keep things simple, especially when you don't understand them well.
And not knowing the basics of generic lists is not acceptable nowadays!
Here is a demo class to describe the combobox items:
Public Class Item
Private myValue As Integer
Private myName As String
Public Sub New(ByVal number As Integer, ByVal name As String)
myValue = number
myName = name
End Sub
Public ReadOnly Property Valu() As Integer
Get
Return myValue
End Get
End Property
Public ReadOnly Property Name() As String
Get
Return myName
End Get
End Property
End Class
and this could be part of a Form that holds a number of comboboxes, all showing the same list, and working fully synchronized:
Private Items As List(Of Item)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Items = New List(Of Item)
Items.Add(New Item(1, "one"))
Items.Add(New Item(2, "two"))
Items.Add(New Item(3, "three"))
For Each ctrl As Control In Me.Controls
If TypeOf (ctrl) Is ComboBox Then
Dim cmb As ComboBox = CType(ctrl, ComboBox)
cmb.DataSource = Items
cmb.DisplayMember = "Name"
cmb.ValueMember = "Valu"
End If
Next
End Sub
That is all there is to it. No magic, no wizards involved.
PS: when you attach a SelectedValueChanged handler to each ComboBox, you'll see they all fire, the one you actually changed fires first, then the others in arbitrary order.
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
Actually I had built this solution (a custom control in connection with a custom 'changed' event both forms shared) before and discarded it – thinking your suggestion would show a completely different approach – because ... this approach only solves a part of my problem, raising another one:
Having every control fire it's changed events I end up actualizing the underlying lists twice (which is time intensive)! I had first tried to avoid that by identyfying the clicked control (passing the sender to the FindForm function), but there' obviously no difference between the index change by a 'real user selection' and a remote index change triggered by the other control's changed-event. Could that effect be avoided?
Regards
Mick
|
|
|
|
|
you could use a global variable GlobalVal to hold the current value of your synchronized comboboxes.
in each SelectedValueChanged handler, compare the new value to GlobalVal; when different do everything that needs to be done and update GlobalVal, when equal do less (or even nothing at all).
Which basically means you would be using a cache with just one entry.
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
Wow - you seem to be online day and night And yes, that makes sense and keeps it simple, too I'm going to check that out.
Thank you in advance
Mick
|
|
|
|
|
Hi,
I would like to register an XLL while installing a project using MSI.
I am using a VB.NET installer class to do this:
Imports System.ComponentModel
Imports System.Configuration.Install
Imports System.ArgumentException
Imports Microsoft.Office.Interop
Public Class Installer1
Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
MyBase.Install(stateSaver)
Dim targetDir = Me.Context.Parameters.Item("targetdir")
targetDir = targetDir.Substring(0, targetDir.Length - 1)
MsgBox(targetDir)
Dim myScript = targetDir + "MySuperAddin.xll"
MsgBox(myScript)
Dim objAddin As Object
Dim objEXL As Excel.Application = DirectCast(CreateObject("Excel.Application"), Excel.Application)
objEXL.Workbooks.Add()
Try
objAddin = objEXL.AddIns.Add(myScript, True)
objAddin(myScript).Installed = True
Catch ex As Exception
MsgBox("cannot open addin. /n Error: " + ex.Message)
Err_Handler:
MsgBox(Err.Description, vbCritical, "Error: " & Err.Number)
End Try
objAddin = Nothing
objEXL.Quit()
objEXL = Nothing
End Sub
End Class
When I run this code as a VB script on my desktop I dont have any issue.
it is a very standard way to install an addin
please see the link
http://stackoverflow.com/questions/1130301/uninstalling-excel-add-in-using-vbscript[^]
However when I run it during the installation I get
Error: 438 Member not found. (Exception from HRESULTS: 0x80020003 (DISP_E_MEMBERNOTFOUND))
I tried to find a solution using the following links:
1) http://support.microsoft.com/kb/172108[^]
and
2) http://support.microsoft.com/kb/213489/[^]
but NO success. it is a clear problem with OLE Automation Object. I would really appreciate a suggestion. MANY THANKS!!
|
|
|
|
|
My Google foo is failing me.
|
|
|
|
|
IIRC a 64-bit version of the OleDb data provider doesn't exist.
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|