 |
|
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
|
 |
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?
|
|
|
|
 |
|
 |
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.
|
|
|
|
 |
|
 |
Message Automatically Removed
|
|
|
|
 |
|
|
 |
|
 |
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 yesterday.
|
|
|
|
 |
|
 |
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.
|
|
|
|
 |
|
 |
Well, it does.[^]
And normally I would be happy about that, but at the moment it's a bit of a problem to solve.
|
|
|
|
 |
|
 |
I stand corrected.
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.
|
|
|
|
 |
|
 |
Curious...why would you want to check?
You're code is going to use the ACE that matches your code bitness. The connection string wouldn't change at all AFAIK.
|
|
|
|
 |
|
 |
It seems that the ACE OleDb that's getting installed with Office is always 32 bits, no matter what your operating system is.
But if you install the Microsoft Access Database Engine 2010 Redistributable you'll have the choice of 32 or 64 bits.
So I want to check not just whether it's installed or not, but also the bitness.
And if it doesn't check I will fallback to Jet OleDb which is preinstalled with the same bitness as the OS.
Or am I missing something obvious here?
|
|
|
|
 |
|
 |
Well, you have no fall back. Why? Bcause you cannot mix 64 and 32-bit code in the same process. This problem is solved at installtime, not runtime.
If your app is compiled as x64 or AnyCPU (and running on a 64-bit O/S), you cannot use the 32-bit drivers. The reverse is also true. If compiled x86 or AnyCPU (and running on a 32-bit O/S), you can't use 64-bit drivers.
The best solution to the problem is to install the requisite software your app needs to run, as is. If your app is compiled x86 or AnyCPU (on a 32-bit machine), then chances are everything is already installed. If your app is compiled AnyCPU (on a 64-bit machine) or x64, then you have to install the Reidistributable engine.
|
|
|
|
 |
|
 |
Does anyone have a LICENCED copy of vsFlexgrid 8 ActiveX surplus to their needs that they wish to sell?
I need to update 1 VB6 prog to run on Win7 but find ComponentOne price is prohibitive for a 1 off job
I understand that this is permitted by the Licence agreement.
Jim
|
|
|
|
 |