|
I just want to start by saying that i have been out of the programming game for a while and i just started to do a little work on a old project of mine. All i want to do is be make a listbox recognize when more than one key is pressed. To be exact, i want ctrl+A to do a select all in the listbox. I figure that .NET has something that i do not know about that is builtin to make this task easy. Thank you for a help that is provided.
|
|
|
|
|
there are two easy ways to get that:
1.
provide a MainMenu and some Menu Item that allows the user to do whatever it is you want the shortcut to do too. Then set the shortcut for that Menu Item. Done.
2.
Set Form.KeyPreview true, provide a Form.KeyDown handler that checks for KeyEventArgs.Control And KeyEventArgs.KeyCode=Keys.A
BTW: you can always get the instantaneous state of the modifier keys from Control.ModifierKeys
|
|
|
|
|
instead of using spaced to space out data how would using tabs spacing instead using code. If would to replace spacing with tab stops instead.
writeline(2) = filename(0) + " " + "Qty" + " " + FormatCurrency(filename1(0)) + " " + "Total Cost"
|
|
|
|
|
when the displaying "device" is tab-capable, it typically interprets a tab as "move to the next position/column number that is a multiple of N" where N is often 8 or 4. So the net effect of a tab character depends on what is present to the left of it, making it not so easy to generate correctly.
if all you need is getting some columnar output, maybe string.PadLeft() and string.PadRight() could fit the bill.
|
|
|
|
|
<pre>writeline(2) = filename(0) + vbTab + "Qty" + vbTab + FormatCurrency(filename1(0)) + vbTab + "Total Cost"</pre>
David Anton
Convert between VB, C#, C++, & Java
www.tangiblesoftwaresolutions.com
|
|
|
|
|
Hi All,
I want to set the width of column of excel while generating excel through code(on button click) in VB application.Any one knows how to do it...!!!!!!
|
|
|
|
|
Columns("C:C").Select
Selection.ColumnWidth = 17.71
Obviously where I have set the specified columns as "C:C" you could set as (Col1:Col2), and where I have put in a set column width you could have a variable.
I hope this helps.------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
|
|
|
|
|
Hi all..i have a form having tabs in VB application.I want to add a text box to one tab only..when i drag and drop the text box-it appears in both the tab.means text box is overriding the form..some one can help me out..how to fix textbox to particular tab..!!
|
|
|
|
|
Place the Tab control on the form
Click the tab for the tabpanel you want to have the control on.
Drag the control onto the panel.
If it appears that the textbox is on both, it is because it is actually on the parent form and is sitting in front of the tab control.
|
|
|
|
|
hi
i m generating a output report in MS word document.
i middle of report few values are based on user input
if user inputs quantity =2 then i want to display two paragraphs
simialary if quantity=3 then i want to display 3 paragraphs
can one help me ...
|
|
|
|
|
MsWrdFile = New Microsoft.Office.Interop.Word.Application
MsWrdFile = CreateObject("Word.Application")
MsWrdFile.Documents.Add()
MsDcmt = MsWrdFile.ActiveDocument
Dim Rg1 As Microsoft.Office.Interop.Word.Range = MsWrdFile.ActiveDocument.Range(Start:=0, End:=0)
MsWrdFile.ActiveDocument.Tables.Add(Rg1, 3, 4)
MsWrdFile.ActiveDocument.Tables(1).Style = "Table Grid 8"
For I As Integer = 0 To 2
Dim oPara_i As Microsoft.Office.Interop.Word.Paragraph
oPara_i = MsWrdFile.ActiveDocument.Content.Paragraphs.Add
If I = 0 Then
oPara_i.Range.Text = "Heading 0"
ElseIf I = 1 Then
oPara_i.Range.Text = "Heading 1"
ElseIf I = 2 Then
oPara_i.Range.Text = "Heading 2"
End If
oPara_i.Range.Font.Bold = True
oPara_i.Format.SpaceAfter = 24 '24 pt spacing after paragraph.
oPara_i.Range.InsertParagraphAfter()
Next
MsWrdFile.Visible = True
MsWrdFile.Quit()
|
|
|
|
|
Hi,
I need to store a string that represent an XML file in a database. In the database, the field is of type ntext. The XML parser will take that field and extract all he needs. The XML parser expect an UTF-8 encoding. Since in VB.Net a string type is UTF-16, I can't create my XML string and store that string in the db because I will have an UTF-16 encoding instead of UTF-8 encoding. What I understand is that in VB I can create a byte array and convert my string to UTF-8 and store that conversion in the byte array. My question: how can I write that array to the field in the database that he is of type ntext?
Thanksmodified on Tuesday, March 9, 2010 8:12 PM
|
|
|
|
|
Change the field type to text. nText is for Unicode, or National Text as defined by SQL-92.
|
|
|
|
|
Unfortunately, I have no control on the database.
|
|
|
|
|
OK. let's see what your code looks like that is storing the XML and retrieving it.
|
|
|
|
|
Actually I don't have my code on hand, but the code look like this:
Dim ms As IO.MemoryStream = New MemoryStream()
Dim w As XmlTextWriter = New XmlTextWriter(ms, Encoding.UTF8)
w.WriteStartDocument()
' create the xml doc by adding element, attribut etc...
w.WriteEndDocument()
w.Flush()
ms.Position = 0
Dim sr As StreamReader = New StreamReader(ms)
Dim strXML As String = sr.ReadToEnd()
Now I have a string that have my xml doc, but because the string type is UTF-16, I need to convert in UTF-8. I can create an array of bytes with the correct encoding like this:
Dim enc As New System.Text.UTF8Encoding()
Dim dBytes As Byte() = enc.GetBytes(strOutput)
I now have an array of byte with the proper encoding but how can I save that in the database where the field is of type ntext?
|
|
|
|
|
What's with the MemoryStream? Why are you not just using a normal SqlParameter object to store the XML text in the field?
|
|
|
|
|
Not sure to understand your question. The memoryStream is used as a container to hold the data created by the XmlTextWriter. Are you suggestion to used the memoryStream has the parameters of a SqlParameter like this:
Dim ms As IO.MemoryStream = New MemoryStream()
Dim w As XmlTextWriter = New XmlTextWriter(ms, Encoding.UTF8)
w.WriteStartDocument()
' create the xml doc by adding element, attribut etc...
w.WriteEndDocument()
w.Flush()
ms.Position = 0
sqlCmd.Parameters.Add(New SqlParameter("@xmlData", SqlDbType.nText))
sqlCmd.Parameters("@xmlData").Value = new SqlXml(ms)
sqlCmd.ExecuteNonQuery
|
|
|
|
|
Convert the MemoryStream to a normal, everyday String and pass the string as a parameter to query.
|
|
|
|
|
Dave, correct me if I'm wrong but if I pass the everyday string type as a parameter, I will have stored an UTF-16 encoding instead of the UTF-8 that I need. The other application that will read the content of that field, will expect an UTF-8 encoding and parse the information to recreate the XML file. (And of course, I have no control on the other application!)
|
|
|
|
|
It gets stored as whatever the original string was. It will NOT change the encoding at all.
Besides, all Strings are Unicode in .NET.
Did you also know that the NTEXT type is deprecated and will be removed from future SQL Servers?
|
|
|
|
|
Thanks Dave for your valuable input.
|
|
|
|
|
TremaHD wrote: The XML parser expect an UTF-8 encoding
why is that?
Can't you just forget about UTF8/UTF16, and store and retrieve strings using Unicode?
i.e. remove the explicit encoding where you open your StreamWriter/StreamReader.
|
|
|
|
|
Hello all
I am building a remote control application on my PDA running WM2003.
I do this using tcplistener and sockets.
I have run into a small problem where I dont know how to do it.
On my main app I have a messagebox opening with ok, cancel.
I want to press OK or Cancel using the remote app on the PDA, any idea how to do this?
Greetings
SiX
|
|
|
|
|
SiXke wrote: I am building a remote control application on my PDA running WM2003.
Remote controling what? Your application, or the entire Desktop on the system?
SiXke wrote: On my main app I have a messagebox opening with ok, cancel.
I want to press OK or Cancel using the remote app on the PDA, any idea how to do this?
This is your app. If your remote controlling just your app, the entire interface is up to you. Provide some method to notify the client that the MessageBox is there and some way for the client to tell the app to dismiss the message box.
If your controlling the entire Desktop and not just your app, Google for "VNC Client". See if anyone has a library that will work with your Windows PDA.
|
|
|
|