|
Hi Richard,
First of all, thanks for your advice. Just two more questions though:
- Do I manually need to replace the forward slashes by back slashes in a Windows environment or does Windows do this for me (Win7/Win8)
- Is WNetGetUniversalName a plug-in I need or just a class I can create (by using the code on the page and just copying and pastng it into a new class?
Cheers!
|
|
|
|
|
Windows should be able to handle paths with forward-slashes. You can also use the Uri class to get back to the absolute path to the file:
Dim basePath As New Uri("\\fileserver\resx\resources\")
Dim pathBAbsolute As String = New Uri(basePath, "../../audio/tracks/track1.mp3").LocalPath
WNetGetUniversalName is a Windows API which isn't exposed through a .NET class. To access it, you have to use a technique called P/Invoke (short for "Platform Invoke"). The code samples on pinvoke.net are usually good enough to get you started.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
hi, i can't view the attached photo because of security of my computer. But here's the codes that i'm using for combining the 3 cell into 1 cell.
]
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.ConnectionString = "Data Source=192.168.xx.xx;Initial Catalog=information;Persist Security Info=True;User ID=me;Password=cute"
cmd.Connection = con
con.Open()
Dim qr As String = "SELECT (Firstname + MI + Lastname) as Full_Name FROM directory1"
Dim ds As New DataSet
Dim da As New SqlDataAdapter(qr, con)
da.Fill(ds, "directory1")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "directory1"
con.Close()
|
|
|
|
|
|
Hello !
I have groupbox with several controls inside.
When a condition is true , I want to prevent users clicking on the controls inside groupbox , but without disabling groupbox or controls.
How can I do that ?
|
|
|
|
|
This is counter-intuitive in the Windows interface application. If a control, like a button, is not greyed out people expect it to be clickable. This is referred to as a "consistent user experience" across all applications running in Windows.
If by "clickable" you mean that the use clicks a button and nothing happens, you have to "unwire" the Click event handler using the RemoveHandler[^] statement. This also means you have to rewire up the handler when you need it to work again, using AddHandler[^].
|
|
|
|
|
Thank you !
The problem is that all these controls are bound to a database .I want that users can see all the data inside these controls ( TextBox , Combobox , ...etc ) all the time. When a condition become true , I want that user can still continue to see the data inside these controls ( If they become grey , is difficult to do that ) but I want to prevent them from modifying the data in these controls.
For me is not a problem that this is a deviation from default behavior in all windows application.
Is possible to prevent user modifying data in the controls inside groupbox without making them grey ?
Thank you !
|
|
|
|
|
Make two copies of the GroupBox. One, is your "readonly" version, where you have TextBoxes for all of your fields. Set the ReadOnly property on those to True. The other is your "edit" copy where you have your normal controls. When the form is in "readonly" mode, hide the "edit" groupbox and show only the "readonly" groupbox.
|
|
|
|
|
Hello !
Ok , but the groupbox have a lot of controls (52 ) and if I duplicate all these , do you think is a good solution ?And The readonly property will make the control grey
I read somewhere about
IMessageFilter .
Can be this a solution for my case ?
And if yes , can you help me with an idea how to implement ?
Thank you !
modified 27-Apr-14 9:53am.
|
|
|
|
|
IMessagFilter isn't going to help you because it filters messages before your application's message pump dispatches messages into events in your code.
You could do it, but it would take a ton of work to get it to filter out keyboard and mouse messages only on some controls and not others. I'm talking far more than just duplicating controls into two differing groups.
By the way, 52 controls to display data seems a bit excessive, but hey, I don't know your app.
modified 1-May-14 11:17am.
|
|
|
|
|
Ok, I'm thinking for another way :
It is possible to make a panel transparent ? , so when the condition is true I can put the panel over my controls , and the user can see the data in the controls , but can't click ?
But to do this I need a transparent panel ???
|
|
|
|
|
It's possible, but Transparent doesn't work the way you think it does in Windows Forms.
A Transparent Backcolor only tells the control to take on the Background properties of the container than holds it. You cannot see other controls through a "transparent" Panel, or any other control in Windows Forms.
You'd have to make your own custom control to do it. Google for "Transparent Panel VB.NET".
|
|
|
|
|
Hello !
I have implemented Imessage filter to resolve my case.
This is the class :
Imports System.Windows.Forms
Public Delegate Sub InsideDelegate(ByRef value As Boolean)
Public Class MyMessageFilter
Implements IMessageFilter
Public Event Inside As InsideDelegate
Private Const WM_LBUTTONDOWN As Integer = &H201
Private Const WM_LBUTTONUP As Integer = &H202
Public Function PreFilterMessage(ByRef m As Message) As Boolean Implements IMessageFilter.PreFilterMessage
Return OnInside()
End Function
Private Function OnInside() As Boolean
Dim _inside As Boolean = True
If InsideEvent IsNot Nothing Then
InsideEvent(_inside)
End If
Return _inside
End Function
End Class
This is the code on my form :
Dim filter As New MyMessageFilter()
Private Flag1 As Boolean = True
Private Sub filter_Inside(ByRef value As Boolean)
value = If((Groupbox1.ClientRectangle.Contains(Groupbox1.PointToClient(Control.MousePosition)) AndAlso Flag1), True, False)
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles Me.Load
AddHandler filter.Inside, AddressOf filter_Inside
Application.AddMessageFilter(filter)
End Sub
This works , but I have some problems :
1)
I have a main form with menu and several other forms. On one of this forms ( not main) I have implemented Imessage filter. But when I close this form , I get an error on this sub :
Private Sub filter_Inside(ByRef value As Boolean)
value = If((GroupBox1.ClientRectangle.Contains(GroupBox1.PointToClient(Control.MousePosition)) AndAlso Flag1), True, False)
End Sub
: An unhandled exception of type 'System.ObjectDisposedException' occurred in System.Windows.Forms.dll
Additional information: Cannot access a disposed object.
What can I do ?
2)
I have noticed a problem in a groupbox that have bound controls.
I have a button that delete records from this form.And if the last record is deleted , I set the flag1 for the GoupBox1 to true ( so not clickable).
but on runtime , when I delete the last record , the bound textboxes should become empty. But they become empty only when I move the mouse outside the groupbox1. ( I didn't have this problem before implementing Imessage filter for this groupcontrol )
What can I do ?
Thank you !
|
|
|
|
|
I told you this wasn't going to work for you without a LOT of work. You're using a sledge hammer to kill a fly.
1) The reason it's telling you the object is disposed is because the filter is still running, but the GroupBox doesn't exist any more. If you Close and Dispose the form, the GroupBox is destroyed, so there's nothing to get a ClientRectangle from!
2) If you called Delete, you TAGGED the record in your DataTable for delete. It does NOT get deleted until you or something else calls AcceptChanges on either the DataRow you deleted or on the DataTable that contains it.
|
|
|
|
|
Thank you !
1) Is possible to use Application.RemoveMessageFilter(filter) on the form's closing method ? Can this resolve the problem ?
2) I call all the methods needed because before implementing Imessage filter everything was worked. But after implementing the imessagefilter on the Groupbox that contain the bound controls , I have this problem. After pressing the delete button , I have a Messagebox to confirm the deletion , and after pressing "Yes" , the mouse pointer remain inside the groupbox . Only If I remove the mouse outside the controls become empty. What can I do ?
Thank you !
|
|
|
|
|
hi everyone,
i need your help!
i successfully merge 3 columns to one column in datagridview but the problem is, there is no spaces between the merged data. And also how to separate data by "/"? My data base is sql and i'm using vb.net2008
thank you in advance
<code>
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.ConnectionString = "Data Source=192.168.xx.xx;Initial Catalog=directory1;Persist Security Info=True;User ID=me;Password=cute"
cmd.Connection = con
con.Open()
Dim qr As String = "SELECT names,(dept + div + pos) as dept_div_pos, tel, local FROM directory1"
Dim ds As New DataSet
Dim da As New SqlDataAdapter(qr, con)
da.Fill(ds, "directory1")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "directory1"
con.Close()
</code>
modified 30-Apr-14 3:06am.
|
|
|
|
|
separate by space
dept + ' ' + div + ' ' + pos
separate by /
dept + '/' + div + '/' + pos
|
|
|
|
|
|
You are welcome. Please accept it as answer. according to CP instruction : "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." Thanks.
|
|
|
|
|
Hi. So I know I've done this before but I can't get it to work despite every example on the internet telling me it should... I'm trying to call a procedure from code. I keep getting an "Invalid SQL statement" exception. Any ideas why? And yes, the procedure compiles and gives no errors when calling from an oracle client.
create procedure DoSomething
as
begin
end DoSomething;
I try to execute from code like so:
Using conn = New OracleConnection(MyConnectionString)
Using cmd = conn.CreateCommand()
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "DoSomething"
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
End Using
End Using
At which point I get the aforementioned exception.
What am I doing wrong?
Sam.
|
|
|
|
|
Does it work when you execute the stored procedure through Oracle?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Yes. This is a only a problem calling the procedure from code.
|
|
|
|
|
You have already posted this question in the Database forum[^].
You've been here six and a half years, and you still haven't realized that cross-posting questions isn't acceptable behaviour?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Oh, I'm terribly sorry that I added another few hundred duplicate bytes the massive amount of data stored here. However will this site possibly be useful now that I've completely gummed it up????
What in incredibly silly thing to get upset about. Report me to the admins, quick!
BTW, since I don't actually know the traffic on the individual discussions and since this question very clearly spans multiple topics, I don't see the problem here. So if you don't like my post and have nothing to contribute other than being a pompous jerk, feel free to pass over my posts.
|
|
|
|