|
I need a quick code to able me to
make a multiple selection useing CommonDialog
i'm useing VB 6
Thx;P
Khalefa...@
|
|
|
|
|
CommonDialog1.Falgs=cdlOFNAllowMultiselect
|
|
|
|
|
Dear Collegues,
I thought I might try to use databindings to create a dialog that will enable a user to change some default colours. I can get the panel to show the colour stored in my class but I can't seem to get the class colour to update when the colour of the panel is changed.
I have a databinding between the BackColor of a Panel control and the LineColour property of a ProjectPreferences Class. The details of each follow. When I show the dlgPrefs dialog, the pnlLineColour.BackColor is correct. After I change the pnlLineColour.BackColor using the ColorDialog, the m_pp.LineColour does not change to suit.
Have I done this correctly or am I expecting too much? I am using VB.NET 2003
I have a class ProjectPrefences which holds the data. e.g. ProjectPreferences.LineColour:-
<br />
Public Property LineColour() As Color<br />
Get<br />
Return m_LineColour<br />
End Get<br />
Set(ByVal Value As Color)<br />
m_LineColour = Value<br />
End Set<br />
End Property<br />
I call the dialog with the following code:-
<br />
Dim MyPrefs As New ProjectPreferences<br />
<br />
Private Sub mnuPreferences_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuPreferences.Click<br />
Dim dlg As New dlgPrefs<br />
dlg.PreferenceData = MyPrefs<br />
If dlg.ShowDialog() = DialogResult.OK Then<br />
MyPrefs = dlg.PreferenceData<br />
End If<br />
End Sub<br />
The Dialog code is:-
<br />
Public Class dlgPrefs<br />
Inherits System.Windows.Forms.Form<br />
<br />
Private m_pp As ProjectPreferences<br />
<br />
Public Property PreferenceData() As ProjectPreferences<br />
Get<br />
Return m_pp<br />
End Get<br />
Set(ByVal Value As ProjectPreferences)<br />
unBindData()<br />
m_pp = Value<br />
If Not m_pp Is Nothing Then<br />
BindData()<br />
End If<br />
End Set<br />
End Property<br />
<br />
''' this routine handles a click in all of the colour panels<br />
Private Sub ColourPanel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pnlLineColour.Click, pnlElementColour.Click<br />
Dim cdlg As New ColorDialog<br />
cdlg.Color = sender.backcolor<br />
If cdlg.ShowDialog = DialogResult.OK Then<br />
sender.BackColor = cdlg.Color 'changes the panel.BackColor<br />
End If<br />
End Sub<br />
<br />
Private Sub BindData()<br />
'pnlElementColour is a Panel on the dialog<br />
Me.pnlElementColour.DataBindings.Add("BackColor", m_pp, "ElementColour")<br />
Me.pnlLineColour.DataBindings.Add("BackColor", m_pp, "LineColour")<br />
End Sub<br />
Private Sub unBindData()<br />
Me.pnlElementColour.DataBindings.Clear()<br />
Me.pnlLineColour.DataBindings.Clear()<br />
End Sub<br />
End Class<br />
Cheers
Tim
|
|
|
|
|
hi!
i use commandbuilder to build sql command to my dataadapter, then i update my dataset, then it return error message contain "syntax error in update statement".
my code was:
private sub update()
dim da as new oledbdataadapter("select * from tabItems",cn) 'cn is oledbconnection
dim cb as new commandbuilder(da)
dim ds as new dataset
da.fill(ds)
'code to modify ds
da.update(ds)
end sub
any help would be useful to me, thanx before...
Ghost
|
|
|
|
|
Yes it can, if you use "*" to denote which fields you want to return. Specify which fields you want, even if it's all of them. You cannot use a "*" in an UPDATE statement in SQL, and that's what the CommandBuilder tried to do.
SELECT field1, field2, field3, field4 FROM tabItems
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
thanx dave, i will try it.
|
|
|
|
|
hi i want to change the width of excel column but it gives error that cannt change read only property,i m using code below
ws.Row[1,2].Entirecolmn.widht=12;//gives error?
how to change the width of excel column
Tasleem Arif
|
|
|
|
|
Hi all,
I am using the following code for my searching function, but when I try to run it, it are allow me to search the item for column 1, but I want to search the item for column 2 as well columun 3, what mistake I have make, can anyone give me some advice on this?
This is my code:,
Private Sub ListView_Master_ColumnClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs) Handles ListView_Master.ColumnClick
Dim exactMatch As Boolean
Dim mySearchText As String
Select Case e.Column
Case 0 'column one BOM ID
'Search for item at column 0 when user click on column 0
'MsgBox(e.Column)
Case 1 'column two Cust Part # = BOM
'Search for item at column 1 when user click on column 1
MsgBox(e.Column)
mySearchText = Trim(InputBox("Please enter your Customer Part #", "Search Product Master Entry Data"))
For Each itm As ListViewItem In ListView_Master.Items
If exactMatch Then
If itm.Text = mySearchText Then
' an exact match was found ...
MsgBox("Exact")
End If
Else
mySearchText &= "*"
If itm.Text Like mySearchText Then
' a partial match was found ...
MsgBox("Partial")
End If
End If
Next
Case 2 'column three Child Part#A = CodeAChild Part#B = CodeB
'Search for item at column 2 when user click on column 2
MsgBox(e.Column)
Case 3 'column three Child Part#B = CodeB
'Search for item at column 3 when user click on column 3
MsgBox(e.Column)
End Select
End Sub
|
|
|
|
|
Could you clarify please? Do you mean that when the user clicks on column 1 it should search column 1, column 2, and column 3? If that is the case, then you need another loop to cycle through the columns before you cycle through the items.
Or do you mean that when the user clicks column 1 it should search column 1 only, and if they click column 2 it should search column 2 only, and so on? In this case what you are saying is that the code is not hitting the Case 2 or Case 3 of your select statement. Try putting a breakpoint at Select Case e.column . Run your program and click on column 2 or 3. Then when it hits the breakpoint quickwatch to see what column you are on. Maybe that can help point you in the right direction.
Sorry I couldn't be more helpful.
|
|
|
|
|
This might be a simple question ..
actually i want to use a tabcontrol in the mdi form (these tab controls should generate at run time) and these should on the left bottom of the page can any one can tell me how to implement this
thanks in advance
chandra
|
|
|
|
|
here you go, modify as necessary.
'dynamically create a tab control and some pages
Dim tbc1 As New TabControl
'format the tab control
tbc1.Dock = DockStyle.Fill
tbc1.Alignment = TabAlignment.Bottom
'add the tab control to the form
Me.Controls.Add(tbc1)
'add 5 pages
Dim x As Integer
For x = 1 To 5
Dim tbp1 As New TabPage
tbp1.Text = "Page " & x.ToString
tbc1.TabPages.Add(tbp1)
Next
|
|
|
|
|
Hi,
I have a VB.Net app that for various reasons is required to load a dll written in C using the LoadLibrary and (when done) FreeLibrary APIs. For the most part everything works perfectly. However there is a problem with one of the functions in the dll, which simply writes an empty file in the users temp directory. When called via the VB.Net app using the following code:
pFunction = GetProcAddress(hDllInstance, f)
If Not pFunction.Equals(System.IntPtr.Zero) Then
Try
CallWindowProc(pFunction, 0, 0, 0, 0)
Catch ex As Exception
End Try
End If
a System.NullReferenceException is always thrown. The file however is written correctly. The function in the dll is simply:
void CreateTempFile()
{
HWND hWnd = CreateFile(szFilePath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_HIDDEN, NULL);
CloseHandle(hWnd);
}
The szFilePath parameter is 1024 chars long (ie. no buffer overruns) and contains the name of the file to create. I created a test program in C to load and test the dll functions and this ran perfectly, both standalone and when run stepwise in a debugger. No exceptions or buffer overruns (etc.) occurred.
I am running the VB.Net app with administrator priviledges. Any ideas would be gratefully received.
Thanks
|
|
|
|
|
I don't think CallWindowProc is going to work for you. I also don't think you can make a direct call to unmanaged code like this.
You might want to take a look at this[^] for an example.
There's also a couple of C# examples here[^]. I don't see an reason why the code couldn't be converted to VB.NET.
Dave Kreskowiak
Microsoft MVP - Visual Basic
-- modified at 20:12 Thursday 13th July, 2006
|
|
|
|
|
Thanks for your reply, this was much appreciated. In actual fact all the calls to CallWindowProc do work, its just that any call that creates a file also raises an exception. I couldn't access the first example you gave (I'm not a paid up member of Experts Exchange) however the other example has given me food for thought. Thanks again for this.
|
|
|
|
|
Hmmm...Things look like they change at the Experts Exchange. I never paidfor a subscription!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Just out of interest the System.NullReferenceException was being thrown as I had declared the CallWindowProc function as:
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As IntPtr, ByVal hWnd As Long, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As String
I "cast" the return value to a string as I would subsequently call this function again to run procedures in the unmanaged dll that returned string values, and I knew no other way to read a string value from memory in .Net Even though I wasn't using the return value in the initial call to CallWindowProc the interop services obviously still attempted to use the value in eax as the address of a string, with the resulting exception being thrown. Simply declaring the return value as an Integer fixed the problem.
|
|
|
|
|
hi i had get the color through color dialog box and saved them in database nd then i want to set on the form?
then i want to set the color of dalog reading from the datbase but it gives error that cannot change readonly property.
System.drawing.color clr=new color();
clr.A=a;//read from db; //gives error that cannot change readonly property
.R=b;
.B=v//et
now i want to set the form color to this.
this.color=clr;
how to assign values to color variables?
Tasleem Arif
|
|
|
|
|
You can't change a color structure once you created it. Use the FromArgb method to create a color from the color components:
clr = Color.FromArgb(a, r, g, b);
---
b { font-weight: normal; }
|
|
|
|
|
Hi. I was wondering how I could use VB.Net code in VS2005 to split a wave file. I am new here I would like to learn some. I don't want others doing my work for me but I would like suggestions! I want to specify the time at which the wave file would be split into two different wave files where I could then save them as separate wave files. Does anybody have a clue? Please! I really need help!
Came here from VBForums......Thought people here could help me.
"Imagination is more important than knowledge." - Albert Einstein.
|
|
|
|
|
A wave file consists of a header and sound data. The header contains data like sample rate and sample size, that you need to know how the sound data is arranged.
What you need to do is to reader the header and the sound data, and construct new headers for the two new files, and split the sound data at the sample you calculate to be at the specified time.
One good source for file formats is Wotsit's format[^].
---
b { font-weight: normal; }
|
|
|
|
|
Hi, I am trying to populate a ComboBox with the contents obtained within an ArrayList, but instead of putting the names held within the ArrayList, it writes "System.Collections.ArrayList" in the place of the desired names.
Could you take a look at my code and see where I am going wrong.
I am using vb.net 2002 version.
Any help is greatly appreciated.
Many thanks
John
This is the code for the function selectFieldNames :-
Public fieldNames As New ArrayList()<br />
<br />
Public Function selectFieldNames(ByVal strSQL As String) As ArrayList<br />
' select all field names from the selected table<br />
sqlite_cmd.CommandText = (strSQL)<br />
' Now the SQLiteCommand object can give us a DataReader-Object:<br />
sqlite_datareader = sqlite_cmd.ExecuteReader()<br />
While sqlite_datareader.Read()<br />
Try<br />
fieldNames.Add(sqlite_datareader("name"))<br />
MessageBox.Show(sqlite_datareader("name"))<br />
Catch es As Exception<br />
MessageBox.Show(es.Message)<br />
End Try<br />
End While<br />
Return fieldNames<br />
End Function
This is the code for populating the ComboBox :-
Private Sub frmCreateIndex_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
dbConn.openExistingDatabse("Data Source=" & getDBName() & ";Version=3;New=False;Compress=True;")<br />
dbConn.createSQLCommand()<br />
<br />
Dim a As Integer<br />
<br />
Try<br />
dbConn.selectFieldNames("pragma table_info(test)")<br />
For a = 0 To (dbConn.fieldNames.Count) - 1<br />
cmbFieldIndex.Items.Add(dbConn.fieldNames)<br />
Next a<br />
Catch es As Exception<br />
MessageBox.Show(es.Message)<br />
End Try<br />
End Sub
|
|
|
|
|
You setup an indexer to go through all the elements of fieldNames but you never used it to return an actual element in the array!
Try
dbConn.selectFieldNames("pragma table_info(test)")
For a = 0 To (dbConn.fieldNames.Count) - 1
cmbFieldIndex.Items.Add(dbConn.fieldNames)
Next a
Catch es As Exception
MessageBox.Show(es.Message)
End Try
Should be:
Try
dbConn.selectFieldNames("pragma table_info(test)")
For a = 0 To (dbConn.fieldNames.Count) - 1
cmbFieldIndex.Items.Add(dbConn.fieldNames(a))
Next a
Catch es As Exception
MessageBox.Show(es.Message)
End Try
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi, thanks for this, works a treat, I can't blieve I forgot to use the array.
Thanks again
John.
|
|
|
|
|
I want to develop sqlserver monitor ,tunerand analyzer please can you guide me how can i do this .. just give me a guideline .. or any opensource lib and prj u know
Features should include: Monitor SQL Server Hardware
requirements are
Utilization and Performance
Monitor CPU, memory, and the I/O subsystem percentages
Monitor disk operations (reads/writes) and network traffic
Correlate system utilization with user connections and SQL code
Diagnose Executed SQL Code Performance, Connections, and SQL Server Blocking
Analyze and chart slow performing SQL statements and stored procedures
Report the cost (Duration, CPU time, & disk reads/writes) of each statement
etc etc
R A M
|
|
|
|
|
SQL Server registers and populates a large number of performance counters - you can use the built in .NET class "PerformanceCounter" to get the current values from that for the first part of your requirement.
For the second part use the "SHOWPLAN" T-SQL commands.
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|