Data column widths...
(Friday, January 06, 2006)
Found the following interesting discussion in the Newsgroups:
Data column widths... by:KC
| Can datagrid column widths be set individually? In the code that is.
Ken
| | | Reply: by:Ken Tucker [MVP]
| | | Hi,
Add a tablestyle to your grid to set the column widths. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchformattingwindowsformsdatagridvisualbasicprimer.asp
Ken
|
Posted by Xander Zelders
How do I get impersonation to work?
Found the following interesting discussion in the Newsgroups:
How do I get impersonation to work? by:Anonymous
| Here is my scenario. I have an ASP.net page that exports a Crystal Report file. When I export the file, the app uses the ASPNET user, which doesn't have the appropriate rights to the network drive that I'm saving the report to.
I thought by adding the <identity impersonate="true" userName="user" password="password"/> to my web.config file would do the trick (obviously giving it a valid user and password). But when I run filemon to look at the access denied error, it shows the user as ASPNET.
I have also tried the following (to no avail):
currentWindowsIdentity = CTypeUser.Identity,System.Security.Principal.WindowsIdentity) impersonationcontext = currentWindowsIdentity.Impersonate()
<code to be run under the impersonation....>
impersonationcontext.Undo()
Am I leaving something out, not doing it right at all ???? I have not tried the LogonUser scenario, as I thought I had this working with just the web.config yesterday, but today, no go...
Any help would be greatly appreciated.
Ed
| | | Reply: by:Anonymous
| | | UnCheck Anonymous access in IIS
| | | Reply: by:Anonymous
| | | If I uncheck anonymous access, which method should I use to impersonate?
1. Setting the user in the web.config file OR.... 2. Using the impersonation code in the code prior to doing the export
Ed
| | | Reply: by:Anonymous
| | | 1. Setting the user in the web.config file <identity impersonate="true" userName="user" password="password"/> OR <identity impersonate="true" /> which will use client's logon username and password
| | | Reply: by:Anonymous
| | | Another thing you muse set "Windows" authentication in web.config
|
Posted by Xander Zelders
Converting from UDT to structure or object - please help
Found the following interesting discussion in the Newsgroups:
Converting from UDT to structure or object - please help by:Clark Stevens
| I have a program that I'm converting from VB6 to VB.NET. It reads in a text file containing barcode numbers and their corresponding descriptions. Then the user enters the barcode number and the program finds the matching barcode description.
In VB6 I used an UDT to store the barcode number along with the description. Then I declared an array of the barcode UDT.
I'm thinking of converting the UDT to a structure in VB.NET and doing something like this:
Structure BCStructure BCNumber as Integer BCDescription as String End Structure
Public BC() as BCStructure
Is there a more efficient way to handle this in VB.NET? Should I setup a barcode class and use an object collection instead? What are the advantages/disadvantages?
All suggestions welcome
| | | Reply: by:Klaus H. Probst
| | | That's OK as long as you're not going to change the number of items in the array, because .NET arrays are immutable.
But you can use an ArrayList, or a Hashtable or any of the other container classes.
But your approach is pretty much there. -- Klaus H. Probst
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
If that's a good solution depends on the number of barcodes. These days we finished a project for university (written in Java :-() that was connected to a barcode scanner to scan barcodes placed on walls. We only had 10 barcodes in our sample, and there will never be more than 100 barcodes. So we simply used a text file containing the number followed by a tab and followed by the description or a filename and loaded it into an array/collection. Then we used linear search to find the item.
Your records are very small, and if there are only few of them, using an array is IMO a good solution. For string IDs, I would use a hashtable, but that's not the case for simple barcode scanners. If there are lots of items and managing them and searching is a complicated process, using a database may be the better solution.
-- Herfried K. Wagner [MVP]
| | | Reply: by:Clark Stevens
| | |
This program will be used with a barcode scanner as well. I don't anticipate there being a lot of records, so it sounds like I am on the right track here. I thank you, and everyone else who responded, for your help. This newsgroup is great!
| | | Reply: by:Mike McIntyre [MVP]
| | | The article at the link below should be helpful.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchUseClassStruct.asp
-- Mike
|
Posted by Xander Zelders
Real beginners stuff
Found the following interesting discussion in the Newsgroups:
Real beginners stuff by:Paul Brownjohn
| Is there a direct equivalent of the VB6 expression 'app.path' in the .NET framework
Cheers
Paul
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
\\Imports System.IO Imports System.Reflection .. .. .. Private Function ApplicationPath() As String Return _ Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location) End Function ///
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
| | | Reply: by:The Grim Reaper
| | | Imports System.Windows.Forms
vAppPath = Application.StartupPath() _______________________________________ The Grim Reaper
|
Posted by Xander Zelders
Datagrid focus
Found the following interesting discussion in the Newsgroups:
datagrid focus by:Randy Fraser
| Anyone know how to get the cursor to land inside the first column of a datagrid after an add.
Me.Datagrid1.CurrentCell = New DataGridCell(Me.dataGrid1.CurrentRowIndex, 0)
will set focus but will not place the cursor inside the textbox in the grid. If I press keys and hit tab, the value
will turn up, but I cannot see the value as I type.
I have tried everything with the exception of what works:-(
Best Regards
Randy
| | | Reply: by:Anonymous
| | | http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q1135q
| | | Reply: by:
| | | Hi Randy
Try this:
CType(me.Datagrid1.TableStyles(0).GridColumnStyles(me.Datagrid1.CurrentCell. ColumnNumber), DataGridTextBoxColumn).TextBox.Focus()
I am assuming that the current tablestyle is the first one. If not either put the number of the style or the mapping name for the table style.
I am also assuming that the gridcolumnstyle is a textbox.
Bob Pfeffer
| | | Reply: by:Randy Fraser
| | | Thanks Bob
This has worked better because I get focus on the column but the cursor still does not want to land (flash) inside the textbox. If I type and press tab, the text will show up. It just won't show up as I type. There maybe another event that is interfearing with it. I will try it on a New form.
Thanks for your help.
Randy
|
Posted by Xander Zelders
Sqlerror numbers
Found the following interesting discussion in the Newsgroups:
sqlerror numbers by:Anonymous
| I'm trying to trap for different sql errors in a try-catch block and would like to find a list of sql error numbers somewhere... anywhere. Can someone direct me? -- Buz Waitz
| | | Reply: by:Lloyd Sheen
| | | Assuming that you are using SQL Server , check Books Online, it is under TroubleShooting/Error Messages in the contents.
Lloyd Sheen like to find a list of sql error numbers somewhere... anywhere. Can someone direct me?
| | | Reply: by:Anonymous
| | | Thank you. That helped. -- Buz Waitz
|
Posted by Xander Zelders
vb.Net Get List available Network Servers (Remote Machines)..
Found the following interesting discussion in the Newsgroups:
vb.Net Get List available Network Servers (Remote Machines).. by:Roger
| I would like to get a list of machines on my network (Workstations and/or Servers).
Is there a way to do this in VB.Net?
Thanks,
Rog
| | | Reply: by:Ken Tucker [MVP]
| | | Hi,
This will only work if you are connected to an active directory. Add a reference to system.directoryservices. Replace NetworkName with your network name.
Dim de As New System.DirectoryServices.DirectoryEntry("LDAP://NetworkName")
Dim ds As New System.DirectoryServices.DirectorySearcher(de)
Dim r As System.DirectoryServices.SearchResult
ds.Filter = "(objectClass=computer)"
Try
For Each r In ds.FindAll
Dim s As String
Console.WriteLine(r.GetDirectoryEntry.Name.ToString)
Next
Catch e As Exception
Console.WriteLine(e.ToString)
End Try This NetServerEnum api will work for a network without a domain. I pasted the code for a sample console app below.
Imports System.Runtime.InteropServices
Module Module1
Structure Computer_info_101
Public Platform_ID As Integer
<MarshalAsAttribute(UnmanagedType.LPWStr)> Public Name As String
Public Version_Major As Integer
Public Version_Minor As Integer
Public Type As Integer
<MarshalAsAttribute(UnmanagedType.LPWStr)> Public Comment As String
End Structure
Declare Unicode Function NetServerEnum Lib "Netapi32.dll" _
(ByVal Servername As Integer, ByVal level As Integer, _
ByRef buffer As Integer, ByVal PrefMaxLen As Integer, _
ByRef EntriesRead As Integer, ByRef TotalEntries As Integer, _
ByVal ServerType As Integer, ByVal DomainName As String, _
ByRef ResumeHandle As Integer) As Integer
Declare Function NetApiBufferFree Lib "Netapi32.dll" _
(ByVal lpBuffer As Integer) As Integer
Private Const SV_TYPE_SERVER As Integer = &H2 ' All Servers
Sub Main()
Dim ComputerInfo As Computer_info_101
Dim i, MaxLenPref, level, ret, EntriesRead, TotalEntries, ResumeHandle As Integer
Dim BufPtr As Integer
Dim iPtr As IntPtr
MaxLenPref = -1
level = 101
ret = NetServerEnum(0, level, BufPtr, MaxLenPref, EntriesRead, TotalEntries, _
SV_TYPE_SERVER, "MSHOME", ResumeHandle) ' Replace MSHOME with your workgroup name
If ret <> 0 Then
Console.WriteLine("An Error has occured")
Return
End If
' loop thru the entries
For i = 0 To EntriesRead - 1
' copy the stuff into our structure
Dim ptr As IntPtr = New IntPtr(BufPtr)
computerInfo = CType(Marshal.PtrToStructure(ptr, GetType(Computer_info_101)), _
Computer_info_101)
BufPtr = BufPtr + Len(ComputerInfo)
Console.WriteLine(computerInfo.Name)
Next
NetApiBufferFree(BufPtr)
Console.Write("Press Enter to End")
Dim s As String = Console.ReadLine()
End Sub
End Module
Ken
|
Posted by Xander Zelders
Where clause with date (asp.net - vb)
Found the following interesting discussion in the Newsgroups:
where clause with date (asp.net - vb) by:Yannick
| Hi,
I try to execute request on a ms-access database but I have a problem with date. the "myDate" field's format is "date/time" my request is:
SELECT myCode, myStuff, myDATE FROM myTable WHERE myDate = #05/21/2004#
in ms-access interface, it works fine ! I get real good lines but when I try to execute in my asp.net vb page, I get "internal automation error" without any other information.
Requests without date stuff inside works, in both asp and access even with a lot of lines in result, so it's not a timeout problem.
executing request with "where myDate = #05/21/2004# " "where myDate LIKE #05/21/2004# " "where myDate = #05/21/2004 00:00:00# " "where myDate LIKE #05/21/2004 00:00:00# " with " # " or " ' " gives me an error
If I change date delimiters to " ' ", I also get an error.
I don't know how to get out of that !
Thanks in advance for any tips !
--yannick-- no direct email reply : fake address
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
Post the code you use tho send the command.
-- Herfried K. Wagner [MVP]
| | | Reply: by:Ken Tucker [MVP]
| | | Hi,
I can't seam to reproduce your error. I tried all your sql statements with the northwind database and got no errors.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here If Not Me.IsPostBack Then BindDataToGrid() End If End Sub
Private Sub BindDataToGrid() Dim strConn As String Dim conn As OleDb.OleDbConnection Dim daOrders As OleDb.OleDbDataAdapter Dim ds As DataSet
ds = New DataSet strConn = "Provider = Microsoft.Jet.OLEDB.4.0;" strConn &= "Data Source = C:\Northwind.mdb;"
conn = New OleDb.OleDbConnection(strConn)
daOrders = New OleDb.OleDbDataAdapter("Select OrderID, OrderDate, ShipVia from Orders where OrderDate LIKE #01/01/1998 00:00:00#", conn)
ds = New DataSet
daOrders.Fill(ds, "Orders")
DataGrid1.DataSource = ds.Tables("Orders") DataGrid1.DataBind() End Sub
Ken
| | | Reply: by:Aaron [SQL Server MVP]
| | |
You might think about using a safe date format, e.g. 2004-05-21.
No, don't ever treat a date column like a string. It is not stored the way it looks!
That's because you're telling Access you're looking for a string. Access expects # for date delimiters.
Followups set to the dotnet group only. This is not related to ASP.
-- http://www.aspfaq.com/ (Reverse address to reply.)
|
Posted by Xander Zelders
how to use SQLDMO/
Found the following interesting discussion in the Newsgroups:
Using SQLDMO by:Craig G
| i am currently building a small user maintenace system which works across different SQL db's and servers.
for a logon screen i am using SQLDMO to get a list of all SQLServers on network, once logged on this then populates a list of db's on that SQL server. by clicking OK i more or less build a connection string for the database that the user wishes to maintain.
one of the maintenace functions is to be able to change the user passwords within the selected db, but i was wondering is there a way via SQLDMO that i can get a list of all Users for that DB, so that i can then populate a listbox with all the users
Cheers, Craig
| | | Reply: by:Anonymous
| | | You could use the system Stored Proc sp_password
Syntax sp_password [ [ @old = ] 'old_password' , ] { [ @new =] 'new_password' } [ , [ @loginame = ] 'login' ]
Syntax and use can be found in the Books Online.
Glenn.
| | | Reply: by:Craig G
| | | yeah i was gonna be using the sp_password to change the passwords anyhow
but what i really wanted was to return a list of users so that rather than type the username in, they can select a username then change the password
Cheers, Craig
|
Posted by Xander Zelders
Books/resources for datagrid?
Found the following interesting discussion in the Newsgroups:
books/resources for datagrid? by:Tarren
| Hi:
I am looking for a strong website/book for the winform datagrid control? Is there a book that deals with this primarily, or a great website for it? I have books on ADO .NET as well as books on Windows Forms Controls, but both touch only lightly on datagrids other than rudimentary binding.
Thanks! -T
| | | Reply: by:Ken Tucker [MVP]
| | | Hi,
http://www.syncfusion.com/FAQ/WinForms/default.asp#44
Ken
| | | Reply: by:Tarren
| | | thanks! perfect!
|
Posted by Xander Zelders
Empty collection
Found the following interesting discussion in the Newsgroups:
Empty collection by:Anonymous
| I am trying to create a component with custom collecion property named FormElements. It can be added to at design time via Collection Editor. But after the project is compiled the FormElements.Count is always 0. Can anyone suggest how to fix it?
Imports system.ComponentModel Imports System.Windows.Forms Imports System.Drawing.Design Imports System.ComponentModel.Design
' -- COMPONENT CODE Public Class QSetup Inherits System.ComponentModel.Component Private m_collection As New QECollection
Public Property FormElements() As QECollection Get Return m_collection End Get Set(ByVal Value As QECollection) m_collection = Value 'm_collection.Add(New QElement) End Set End Property
' -- Component Designer generated code < -- OMITTED FOR SIMPLICITY
End Class
' -- CUSTOM COLLECTION CODE
Public Class QECollection Inherits System.Collections.CollectionBase
Public Sub Add(ByVal QE As QElement) MyBase.List.Add(QE) End Sub Default Public Property Item(ByVal index As Integer) As QElement Get Return MyBase.List.Item(index) End Get Set(ByVal Value As QElement) MyBase.List(index) = Value End Set End Property End Class
' -- Public Class QElement
Public Enum ControlType Textbox Checkbox End Enum
Private m_ctrl_type As Integer = 0 Public Property Controls() As ControlType Get Return m_ctrl_type End Get Set(ByVal Value As ControlType) m_ctrl_type = Value End Set End Property Private m_label_text As String Public Property LabelText() As String Get Return m_label_text End Get Set(ByVal Value As String) m_label_text = Value End Set End Property
End Class ' --------------------------
Thanks very much, Roman
| | | Reply: by:Marina
| | | Try putting a DesignerSerializationVisibilityAttribute on your FormElements property, setting it to Content.
A good way to check if things are working right, is to see if the designer is generating code to add the items to the collection in InitializeComponent. If not, then the addition of items is not being serialized into code, and so when you compile and run (or just go back into the designer), the collection is empty.
Also, I think you will need to make your QElement class a component.
| | | Reply: by:Anonymous
| | | Marina, By your advice I checked the the count property in InitializeComponent event and it was 0! So it didn't make sense to continue with running the project. I tried DesignerSerializationVisibility attribute but it didn't fix the problem. Next ,as you suggested, I will try making my QElement class a component and will let you know of the result. Thanks, Roman
| | | Reply: by:Roman
| | | Marina,
Once I replaced my class with a component everything worked fine.
Thank you very much for your help.
|
Posted by Xander Zelders
Displaying / Refreshing Dialog Box from System Tray mouse-click pr
Found the following interesting discussion in the Newsgroups:
Displaying / Refreshing Dialog Box from System Tray mouse-click pr by:Anonymous
| Hi,
I'm pretty new to VB.Net and I have an application that I am writing which consists of a system-tray icon, that periodically checks things on the computer.
When the check occurs, I want to display a dialog box that contains a progress bar along with messages that indicate what is currently happening.
I can get the dialog box to display, but it only shows information after everything is complete. I've tried every which way that I know of to update/refresh the dialog box, but nothing seems to work.
Any help would be greatly appreciated.
Many thanks
Martin Russ
| | | Reply: by:Ken Tucker [MVP]
| | | Hi,
Post your code.
Ken
| | | Reply: by:Anonymous
| | | Here's the Startup function that get's called from the main code. It's called using the ShowDialog function.
Public Function Startup()
Dim nMax As Integer Dim szZip As String
Me.Invalidate() Me.Refresh() Label1.Refresh() Label2.Refresh() Operation.Refresh()
System.Windows.Forms.Application.DoEvents()
'Check the status... nMax = GetFiles() nMax -= 1
' Do something... szCpy = CopyFiles(nMax)
' Encrypt... Operation.Text = "Copying files..." Operation.Refresh() CopyFiles(szCpy) ProgressBar1.Value = 100 ProgressBar1.Refresh()
'I even tried a for...next loop to see of Windows would refresh the dialog... Dim x For x = 0 To 1200000
Next
' Move the files to their new location... Operation.Text = "Moving files..." Operation.Refresh()
szMove = szCpy PassiveMove(szCpy)
End Function
I have labels that need refreshing with different messages along the way, and nothing ever happens...even the progress bar doesn't move...not until everything is done, then it's 100% with the last message.
|
Posted by Xander Zelders
SMTPMAIL Format & File Link??
Found the following interesting discussion in the Newsgroups:
SMTPMAIL Format & File Link?? by:B-Dog
| I've built a form that I want to use to email some of the information off it to a few users which will include a link to a folder on our network. I'm trying to send it in html format but when the message is received all you see is the html code and not just the text. I've included the code below but I'm a rookie so I must be missing something or doing something wrong. Thanks!
Barclay
Sub sendmail()
Dim email As MailMessage = New MailMessage
Dim stringMessage As String
Dim uName As String
uName = "user@domain.com"
'message string with link
'stringMessage = "<BODY>Click the link below to open directory<A href=""file://z:\pending move\" & TextBox1.Text & "\"">file://z:\pending move\& textbox1.text & ""\</A> </BODY>"
stringMessage = "<html><body>UtilMailMessage001->success</body></html>"
email.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer = "mail.domain.net"
SmtpMail.Send(uName, "user@domain.com", "New Files Ready to be Archived in folder: (" & TextBox1.Text & ")", stringMessage)
End Sub
| | | Reply: by:Anonymous
| | | you need to include the <html> tags also. Try this:
Dim newMail As New MailMessage
newMail.From = MailFrom newMail.To = MailTo newMail.Subject = Subject newMail.BodyFormat = MailFormat.Html newMail.Body = "<html><head><title>" & Subject & "</title></head><body>" & Message & "</body></html>" SmtpMail.Send(newMail)
| | | Reply: by:Anonymous
| | | Try this:
Dim newMail As New MailMessage
newMail.From = MailFrom newMail.To = MailTo newMail.Subject = Subject newMail.BodyFormat = MailFormat.Html newMail.Body = "<html><head><title>" & Subject & "</title></head><body>" & Message & "</body></html>" SmtpMail.Send(newMail)
Also make sure the mail server you are sending through and the destination mail server support html email.
Best Regards,
Jennifer M.G. Parks
| | | Reply: by:B-Dog
| | | Thanks for the help, I had some of my quotes screwed up.
|
Posted by Xander Zelders
Select row only in datagrid?
Found the following interesting discussion in the Newsgroups:
select row only in datagrid? by:Tarren
| Hi:
I am wanting to make it so that a user cannot select a single cell in a row, but can only select the entire row. Can someone point me in the right direction as to how to accomplish this. I worked with the styles and if the person clicks in the row selector on the left, then it highlights the whole row, but I would like it that if they click anywhere on the row (any cell) it will select the whole row, and not just that cell..
What I am wanting to accomplish is that the the user picks a row from the list and it displays the details below the grid in another control.
Thanks!
- T
| | | Reply: by:Arne Janning
| | | Tarren wrote:
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q689q
Cheers
Arne Janning
| | | Reply: by:Tarren
| | | Thanks so much! That site is exactly what I have been looking for!
|
Posted by Xander Zelders
VB.Net get list of Services on Remote Computer.... How?
Found the following interesting discussion in the Newsgroups:
VB.Net get list of Services on Remote Computer.... How? by:Roger
| I would like to get a list of services on a remote computer. Is this possible via code in VB.Net? Thanks,
Rog
| | | Reply: by:Jay B. Harlow [MVP - Outlook]
| | | Roger, Window Services or Web Services.
For Windows Services have you tried:
System.ServiceProcess.ServiceController.GetServices?
The GetServices is overloaded to retrieve both services local to the machine, and services on a remote machine.
Dim services() As ServiceController services = ServiceController.GetServices("MyServer")
Hope this helps Jay
|
Posted by Xander Zelders
TabControl & DataBinding
Found the following interesting discussion in the Newsgroups:
TabControl & DataBinding by:Agnes
| Now, I understand my problem (bugs?) about the Tab Control & dataBinding 1)a simple blank form with tabcontrol , there are 2 pages, pages1 got 3 textboxes (txtShipperNAme,txtJobNo,txtVslName) and one "New" button 2)As Formload, I will fill in the dsInvoice and bind the data dsSeaExHBL.Clear() daSeaExHBL.Fill(dsSeaExHBL, "BillLadingHeader") bmSeaExHBL = Me.BindingContext(dsSeaExHBL, "BillLadingHeader") Me.txtShipperName.DataBindings.Add("text", dsSeaExHBL, Me.txtVslName.DataBindings.Add("text", dsSeaExHBL, Me.txtJobNo.Text = "" 3) in New button's click Event, bmSeaExHBL.EndCurrentEdit() bmSeaExHBL.AddNew() 4) I start to input the data , then I click the Tab Page2, and then I click back Tab Page1. 5)Bugs:- txtShipperName & txtVslName 's Text got blank [It seems loss what I input before] 6) For txtJobNo, the data still remain in TextBox.
What's wrong with Tab Control ??? Thanks From Agnes
| | | Reply: by:Anonymous
| | | It should be a bug: Seems everytime back to page1 cause refreshing databind. Use following code to avoid the situation:
Private Sub txtVslName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtVslName.TextChanged bmSeaExHBL.EndCurrentEdit() End Sub
| | | Reply: by:Cor Ligthert
| | | Agnes,
I have tried to do your problem, see this sample and tell me after trying that what is different with what you write and what is the problem or even this sample solved your problem?.
I used a datatable that I made with one column however that is in my opinion basicly not different from three columns.
Cor
'sample a form with on that a tabcontrol 'with two tabpages 'on tabpage 1 a textbox and a button 'on tabpage 2 a listbox 'and than pasted in Private cma As CurrencyManager Dim dt As DataTable Private Sub Form1_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.Load dt = New DataTable dt.Columns.Add("Name") For i As Integer = 0 To 1 dt.Rows.Add(dt.NewRow) Next dt.Rows(0)(0) = "Agnes" dt.Rows(1)(0) = "Marina" 'Before only to make a table cma = CType(BindingContext(dt), CurrencyManager) Me.TextBox1.DataBindings.Add("text", dt, "Name") Me.ListBox1.DataSource = dt Me.ListBox1.DisplayMember = "Name End Sub Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click cma.AddNew() End Sub
|
Posted by Xander Zelders
Copy folder during deployment
Found the following interesting discussion in the Newsgroups:
copy folder during deployment by:magnus@rad-o-resultat-dot-se.no-spam.invalid (magmo)
| Hi I need to have a folder with some files in it copied to the clients computer. How can I configure this when I deploy the application I've developed? Regards Magnus
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
Inside the setup project, have a look at the buttons above the "solution" explorer. There is one view that will show you the file system of the destination computer. You can place the files to be copied there.
-- Herfried K. Wagner
|
Posted by Xander Zelders
How to get the last control in focus?
Found the following interesting discussion in the Newsgroups:
getting the last control in focus by:Sameh Ahmed
| Hello there Is there a way to get the last control that was in focus before the current control? please note that I don't want the next or previous control in the tab order, I need the last one used by the user. Thanks in advance. Regards Sameh
| | | Reply: by:Cor Ligthert
| | | Hi Sameh,
I do not know if that is standard on the other hand in my opinion is it not to difficult to make When you build a general lost focus event than you can set the last control name in that. Than you know always what was the last.
Just a thought I do not remember it if I ever did tried it.
Cor
| | | Reply: by:Sameh Ahmed
| | | Hello Cor may I ask what do you mean by a general focus event, how do you do that? it will be a hell of a job to create a lost focus event for every control on each form! Thanks for your time Regards Sameh
| | | Reply: by:Cor Ligthert
| | | Hi Sameh,
Fool I am, it is my standard sample for setting dynamicly handlers. Set some textboxes than you see everytime the name in the last.
I hope this helps?
Cor
\\Dim last As String Private Sub Form5_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.Load doset(Me) End Sub Private Sub doSet(ByVal parentCtr As Control) Dim ctr As Control For Each ctr In parentCtr.Controls AddHandler ctr.LostFocus, AddressOf meLostFocus AddHandler ctr.GotFocus, AddressOf meGotFocus doSet(ctr) Next End Sub Private Sub meLostFocus(ByVal sender As Object, _ ByVal e As System.EventArgs) last = DirectCast(sender, Control).Name End Sub Private Sub meGotFocus(ByVal sender As Object, _ ByVal e As System.EventArgs) DirectCast(sender, Control).Text = last End Sub ///
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
Recursively loop through the controls and add a handler to their 'LostFocus' event. This handler will receive the event for all controls. Inside the handler, you can cast 'sender' to 'Control' and assign it to a private member.
-- Herfried K. Wagner [MVP]
|
Posted by Xander Zelders
What up
Found the following interesting discussion in the Newsgroups:
What up by:CJ Taylor
| Hey everyone,
Hope all is going well, must admit missed you all... but had to go do that marriage thing.. =)
Any excitement while I was gone? =)
| | | Reply: by:Cor Ligthert
| | | HI CJ,
Great to see you back, I was afraid there was something wrong, however now I see you are married, so my wishes for a lot of good luck.
Not much happened, OHM is back, however he is not doing his weekly/daily joke anymore I think that it is to make Herfried more happy.
Cor
| | | Reply: by:CJ Taylor
| | | Hey Cor,
Good to hear from you. Hope your doing well. Yeah, my left hand seems to be dragging on the ground a lot and find myself always saying "I have to check with my wife." but otherwise all is well.
Glad to see OHM is back, haven't seen him in a long time. Hope you and herfried are doing well, I should be fully back in the game by next week.
Peace
CJ
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
:-)))
-- Herfried K. Wagner [MVP]
| | | Reply: by:One Handed Man \( OHM - Terry Burns \)
| | | You fool !
--
OHM ( Terry Burns )
|
Posted by Xander Zelders
Objects, Nothings and Nulls!!!!
Found the following interesting discussion in the Newsgroups:
Objects, Nothings and Nulls!!!! by:Alex Stevens
| Hi All,
I'm working on my Data access class which has an .AddParamter Function. (Code is at the end of the message). One of the parameters of this Function is the value which should entered into an SQLClient.SQLParameter object.
This is declared as Object because I could be accepting dates, string, ints into the parameter. However, I wish to be able check if the value supplied is Nothing and set it to System.DBNull.Value, so that it is passed to the SQL server correctly as a Null.
When I pass an int (set to Nothing) into the Value Parameter and check the varValue object like this in the command window:
varValue = Nothing 'This evaluates to True varValue Is Nothing 'This evaluates to False.
But I can't use "If varValue = Nothing" in the function the compiler won't allow it - "Use the IS operator to test for object identity" But if I use "If varValue Is Nothing" in the function it is incorrect for an integer.
How can I get my code to correctly recognise an integer passed into an object and test "varValue = Nothing" and recognise a object passed in and text "varValue Is Nothing"?????
Many Thanks
Alex Public Function AddParameter(ByVal strParamName As String, _ ByVal sqlParamType As System.Data.SqlDbType, _ Optional ByVal sqlParamDir As System.Data.ParameterDirection = ParameterDirection.Input, _ Optional ByVal intSize As Integer = 0, _ Optional ByVal varValue As Object = Nothing, _ Optional ByVal ConvertNothingToNull As Boolean = False) As SqlClient.SqlParameter
Dim sqlParam As New SqlClient.SqlParameter
If varValue Is Nothing And ConvertNothingToNull Then
End If
With sqlParam .ParameterName = strParamName .SqlDbType = sqlParamType .Direction = sqlParamDir .Size = intSize .Value = varValue End With
m_cmdCommandSQL.Parameters.Add(sqlParam)
Return sqlParam
End Function
| | | Reply: by:Cor Ligthert
| | | Hi Alex
I think you can do it like this sample below, but in my opinion a lot of work to keep a variable variable, it takes as well a more time to use that boxed variable.
However, I hope this helps?
Cor \\Dim myobject As Object if Not myobject Is Nothing Then If TypeOf myobject Is Integer Then If DirectCast(myobject, Integer) <> Nothing Then 'do something by instance dim myrealinteger = CInt(myobject) 'I show you with this two different methods of the cast End If ElseIf TypeOf myobject Is String Then 'etc End If End If ///
| | | Reply: by:Jay B. Harlow [MVP - Outlook]
| | | Alex, ints I would seriously consider Overloading instead of passing an Object parameter.
Public Sub AddParamter(..., value as Date) Public Sub AddParamter(..., value as String) Public Sub AddParamter(..., value as Integer) Public Sub AddParamter(...)
The last one would set the parameter to DBNull.Value, while the first three sets the parameter to the value passed.
Note that its tricky to Overload when you have Optional parameters, I would stick with Overloading and not use the Optional parameters. In fact I rarely use Optional parameters, especially in cases like this. I will use Optional parameters when its clear what the missing Optional really means...
the When you set an Integer to Nothing, you are setting the Integer to its default value, which is 0. Seeing 0 is a valid value for Integer, you cannot check the object parameter for Nothing, as the Integer will never be the Nothing reference.
Hope this helps Jay
| | | Reply: by:Anonymous
| | | further to Jays comment, consider using the SqlInt32 instead of Integer as this IS nullable
hth
guy
|
Posted by Xander Zelders
deploy a class
Found the following interesting discussion in the Newsgroups:
deploy a class by:Frank
| Hi, I have a formA and classB which I want to wrap into a component so my fellowworkers can use the formA in their main applications. ClassB must not be visible. How do I do this? I can only find info about deploying complete applications, but this is just a subform and a class. I want my fellowworkers to use my formA instead of a standard form. And they must be able to see the intellisense info when using the formA. Thanx Roy
| | | Reply: by:Supra
| | | http://msdn.microsoft.com/vbasic/atthemovies/deploy/default.aspx
| | | Reply: by:Frank L
| | | Supra, there is no hint to whatsoever about deploying a class
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
Declare the form as 'Friend'.
-- Herfried K. Wagner [MVP]
|
Posted by Xander Zelders
Tabcontrol
Found the following interesting discussion in the Newsgroups:
tabcontrol by:afsheen
| Hi
iam using a tabcontrol in vs.net and wanted to know that could i shift from one tabpage to another by pressing the tab keys when the last control of that tab page loses focus
thanks
| | | Reply: by:Anonymous
| | | You sure can. On the leave event of the last control on that tab page call "TabControl.SelectedIndex" set it to the Tab page you wish to go to. TabPageIndex as int.
TabControl1.SelectedIndex = 2
Should take you to the next Tab
| | | Reply: by:Anonymous
| | | Use arrow keys
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
Users don't like non-standards-conform behavior of UI elements...
-- Herfried K. Wagner [MVP]
|
Found the following interesting discussion in the Newsgroups:
tabcontrol by:afsheen
| Hi
iam using a tabcontrol in vs.net and wanted to know that could i shift from one tabpage to another by pressing the tab keys when the last control of that tab page loses focus
thanks
| | | Reply: by:Anonymous
| | | You sure can. On the leave event of the last control on that tab page call "TabControl.SelectedIndex" set it to the Tab page you wish to go to. TabPageIndex as int.
TabControl1.SelectedIndex = 2
Should take you to the next Tab
| | | Reply: by:Anonymous
| | | Use arrow keys
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
Users don't like non-standards-conform behavior of UI elements...
-- Herfried K. Wagner [MVP]
|
Posted by Xander Zelders
Pprogressbar
Found the following interesting discussion in the Newsgroups:
progressbar by:magnus@rad-o-resultat-dot-se.no-spam.invalid (magmo)
| Hi
I wonder if there is someone that can show me how I can use a progressbar that indicate how a file creation procedure is going. I have the file creation as a class. Regards Magnus
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
Does this class provide any feedback meachanism? For example, you could define an event in the class ('ProgressChanged' or similar) that is called when the progress of the writing process changed a certain amount. Then you can instantiate the class and add a handler to this event to update the progressbar.
-- Herfried K. Wagner [MVP]
| | | Reply: by:magnus@rad-o-resultat-dot-se.no-spam.invalid (magmo)
| | | Hi There is currently no such thing in the class, would it be easier if I just made a sub routine in the form. Could I then easier have a progressbar that indicate how the creation of files is going?
Regards Magnus
|
Posted by Xander Zelders
Transparent?
Found the following interesting discussion in the Newsgroups:
Transparent? by:Xavier Valdés
| Hi all,
I'm trying to see files from listview control so I'm adapting VBResourcekit sample "Windows Forms - Create an Explorer Style Application" with different icons capabilities. For doing that, I'm filling and imagelist every time I want to showfiles(). In this function, I'm using api's SHGetFileInfo (is the only way of doing that?) so as to get every icon of every kind of file. I've read it in the following sample: http://www.codeguru.com/vb/gen/vb_misc/icons/article.php/c5597
Well, the problem is I see icon's transparency in black and it's too ugly for my application. I've tried to force like this:
img.TransparentColor = System.Drawing.Color.Transparent But I didn't got the expected result... I need help!!!
Thank your very much,
Xavier
| | | Reply: by:onurbyk
| | | Hi xavier,
you can try following sample provided by Jeff Key, http://www.sliver.com/dotnet/HighColorIcon/
onurbyk
| | | Reply: by:Xavier Valdés
| | | Thanks a lot!
|
Posted by Xander Zelders
Add Form/Control "The Operation Could Not Be Completed"
Found the following interesting discussion in the Newsgroups:
Add Form/Control "The Operation Could Not Be Completed" by:Mark
| Hi,
I'm running visual studio 2003, and am now receiving the error "The Operation Could Not Be Completed" when attempting to add a form / control or component class to a project. I can add any other type of item without a problem. This is the second time this has happened to my machine, last time I reinstalled VS and it fixed it. I havent installed anything since that time, so I guess it must be some sort of corruption in the system. Our projects are bound to sourcesafe, but even if I create a new project ( that is not bound to source control ) I still cannot create forms etc.
Anyone have any ideas on what is causing this and any possible solution ?
Thanks
Mark
| | | Reply: by:laci.sz@gmail.com (Laci Szomoru)
| | | Hi Mark,
You should try to reinstall the Windows Script. Get the installation file from the Microsoft site: http://www.microsoft.com/downloads/details.aspx?FamilyId=C717D943-7E4B-4622-86EB-95A22B832CAA&displaylang=en
Reinstall, restart and try to see if you can create projects now.
| | | Reply: by:Mike Smith
| | | ive had similar problems.. mine was related to addin controls to a web form.. i found it usually happened when i had too many windows (of web pages, classes, etc) open at the same time. I just had to issue a SAVE ALL , close the windows that were open and add the control on the form and then it worked. no clue really why.... memory issue? well as long as it keeps working..
|
Posted by Xander Zelders
Fast file access reading text file line per line
Found the following interesting discussion in the Newsgroups:
Fast file access reading text file line per line by:Volker Jobst
| Hi,
Is there a really fast way to read a text file which contains lines of variable length? I'm using the StreamReader to read the file, but this is not as fast as I need it.
thanks a lot volker jobst
| | | Reply: by:Cor Ligthert
| | | Hi Volker,
And you are using the ReadToEnd method?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemiostreamreaderclassreadtoendtopic.asp
Cor
| | | Reply: by:Volker Jobst
| | | Thanks for your reply, but I cannot use the ReadToEnd method because I have to manipulate the read contents line per line, so I have to read the file line per line to.
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
Post your code.
-- Herfried K. Wagner [MVP]
| | | Reply: by:Volker Jobst
| | | I think I found out what the problem is. When I just read the file without manipulating the read line, it's really fast, so I have to improve these lines. thanks for given me this hint.
volker jobst
|
Posted by Xander Zelders
Is it possible for some nodes not to show checkbox?
Found the following interesting discussion in the Newsgroups:
Is it possible for some nodes not to show checkbox? by:Shelby
| Hi,
I understand that the "TreeView" has the property "checkbox". I wonder is it possible for some nodes not to show the checkbox while others continue to show?
Shelby
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
That's not supported out of the box. You will have to use p/invoke to remove/change the checkbox. A VB6 sample can be found here:
<URL:http://www.mvps.org/btmtz/treeview/tvcheckboxesex.zip>
-- Herfried K. Wagner [MVP]
|
Posted by Xander Zelders
Button and detect key pressed
Found the following interesting discussion in the Newsgroups:
Button and detect key pressed by:Anonymous
| Hi,
I have a form with a button and when I click in this button, how I can detect the keys pressed and put this keys pressed in text property of the button.
Thanks
Silvia
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
Set the form's 'KeyPreview' property to 'True', add a handler to its 'KeyDown' and 'KeyUp' events and store the pressed keys for example in a 'Hashtable'. In 'KeyUp', you can remove them from the table (untested).
-- Herfried K. Wagner [MVP]
| | | Reply: by:Cor Ligthert
| | | Hi Silvia,
Have a look at this page (it is for a webform however even more described than for a windowform)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskrespondingtobuttonwebcontrolevents.asp
I hope this helps?
Cor detect the keys pressed and put this keys pressed in text property of the button.
|
Posted by Xander Zelders
How can I convert ANSI to OEM in VB.net ?
Found the following interesting discussion in the Newsgroups:
How can I convert ANSI to OEM in VB.net ? by:nicksop
| How Can I convert ANSI to OEM with StreamWriter ?
| | | Reply: by:Jay B. Harlow [MVP - Outlook]
| | | Nicksop, Remember that when you read a file into a string it is converted from the encoding in the file to Unicode, that when you write it is converted from Unicode to the encoding in the file.
You can use System.Text.Encoding.Default to get the current Windows ANSI Code page encoding object. You can use System.Text.Encoding.GetEncoding to get a specific code page (such as an OEM one).
You can use the System.Globalization.CultureInfo.CurrentCulture.TextInfo.OEMCodePage to get the current OEM code page.
Imports System.IO Imports System.Text Imports System.Globalization Dim input As New StreamReader(inputPath, Encoding.Default) Dim output As New StreamWriter(outputPath, False, Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.OEMCodePage))
Dim line As String
line = input.ReadLine() Do Until line Is Nothing output.WriteLine(line) line = input.ReadLine() Loop input.Close() output.Close()
Hope this helps Jay
| | | Reply: by:
| | | Thank you very much Jay,
I havent'nt thought that solution !! Thank you very much for your time!
|
Posted by Xander Zelders
How to set a tip text on a button control
Found the following interesting discussion in the Newsgroups:
How to set a tip text on a button control by:Anonymous
| Hi,
I'd like to know how to set a tip text onto a button control. i.e., to provide some information when users move the mouse over a button.
Thanks in advance
| | | Reply: by:Anonymous
| | | Here is the link may be what I need. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformstooltipclasstopic.asp
| | | Reply: by:One Handed Man \( OHM - Terry Burns \)
| | | So easy. Drag a ToolTip control onto the form.
and IE
ToolTip1.SetToolTip(btnUP, "Here's how!") --
OHM ( Terry Burns )
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
From the toolbox, add a ToolTip component to your form. This component will show up in the component tray below the Windows Forms editor for the form. Then have a look at the button's properties -- there will be an additional property where you can set the text of the tooltip for the button control.
-- Herfried K. Wagner [MVP]
|
Posted by Xander Zelders
Can someone explain observer patterns for me?
Found the following interesting discussion in the Newsgroups:
Can someone explain observer patterns for me? by:Lars Netzel
| Hi!
I have looked into it a little and I did'nt get much. How does it basically work?
/Lars Netzel
| | | Reply: by:One Handed Man \( OHM - Terry Burns \)
| | | http://www.phppatterns.com/index.php/article/articleview/27/1/1/
--
OHM ( Terry Burns )
| | | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
| | |
<URL:http://msdn.microsoft.com/library/en-us/dnpatterns/html/ImpObserverInNET.asp>
-- Herfried K. Wagner [MVP]
| | | Reply: by:cleo
| | | i just viewed this webcast. i found it very helpful.
|
Posted by Xander Zelders
Datagrids
Found the following interesting discussion in the Newsgroups:
datagrids by:jhsu8999@hotmail.com
| Hi, all: In VB6, I can do this: private sub someGRD_keypress(ascii as integer) 'if user press 'enter' then do.... if (ascii = 13) then ....... end if end sub
How can I do this in VB.NET? Thanks.
| | | Reply: by:Lars Netzel
| | | Just create the Sub in Visual Studio to get the right arguments and stuff... then use parameter e to compare things with.
I think e.KeyChar will give you what you need on KeyPress. KeyDown will give you other arguments.
/Lars
| | | Reply: by:Cor Ligthert
| | | Hi did you know that there is for questions "How to do in dotNet what was in VB6" is a special newsgroup.
microsoft.public.dotnet.languages.vb.upgrade
Cor
|
Posted by Xander Zelders
System.Diagnostics.Process.Start and launching notepad
Found the following interesting discussion in the Newsgroups:
System.Diagnostics.Process.Start and launching notepad by:andreas
| hi,
In windows xp in the start launch menu when i put notepad "c:\test.txt" i get notepad with test.txt in it.
in vb.net when i state system.diagnostics.process.start("notepad.exe" i get notepad but system.diagnostics.process.start("notepad.exe c:\test.txt") don't work can i get the file test.txt in notepad ? Thanks for any response
| | | Reply: by:M. Zeeshan Mustafa
| | | Hi,
in this code: system.diagnostics.process.start("notepad.exe c:\test.txt")
I think that you want to open c:\test.txt in notepad.exe.
process.start has a constructor thru which you can pass arguments to starting process.
try this: System.Diagnostics.Process.Start("notepad.exe", "c:\test.txt")
-- Hope this helps, Zeeshan Mustafa
| | | Reply: by:Cor Ligthert
| | | Hi Adreas,
I hope that this sample helps?
Cor
\\Public Class Main Public Shared Sub Main() Dim p As New Process p.StartInfo.UseShellExecute = True p.StartInfo.Arguments = "c:\text.txt" p.StartInfo.FileName = "notepad.exe" p.Start() End Sub End Class ///
|
Posted by Xander Zelders
Prevent Auto Rounding
Found the following interesting discussion in the Newsgroups:
Prevent Auto Rounding by:Keith
| Hello, Let's say Textbox1.text = 10 size = 46
answer = (Val(TextBox1.Text) * 100.5) / size TextBox2.Text = Format(answer, "#######.000")
The answer is: 21.847830... However, when I get the result in textbox2.text - it shows: 21.848
While I understand that this is rounding up - how can I make it so that I still get the 3 decimal places - but it shows: 21.847 (without the rounding)
| | | Reply: by:Cor Ligthert
| | | Hi Keith,
Microsoft has used the International Banking standard. When you ask in this newsgroup who is using that than there comes no answer. You have to do rounding with your own routines.
See here the questions and answer in the language.vb which has been about rounding.
http://tinyurl.com/353eu
I hope this helps?
Cor
| | | Reply: by:Ian Mooney
| | | Keith,
You have 2 options, use the INSTR and LEFT functions OR multiply the value up, convert it using the INT function then divide it back down. See examples below;
Option 1: Dim Answer as String Dim Ptr As Integer Answer = CStr( (10 * 100.5) / 46) 'Calculate your value and convert to a string Ptr = Instr(Answer, ".") 'Check if the result has a DECIMAL If (Ptr = 0) Then 'If there is NOT a decimal TextBox2.Text = Answer 'Display the answer as-is Else 'Otherwise TextBox2.Text = Left(Answer, Instr + 3) 'Display the string up to the Decimal + next 3 characters End If
Option 2: Dim Answer As Double
Answer = (10 * 100.5) / 46 Answer = Answer * 1000 Answer = Int(Answer) Answer = Answer / 1000 TextBox2.Text = Answer.ToString
NOTE: In Option 2 you could perform all the math on 1 line as in; TextBox2.Text = (Int(((10 * 100.5) / 46) * 1000) / 1000).ToString
|
Posted by Xander Zelders
TabControl&databind problem
Found the following interesting discussion in the Newsgroups:
TabControl&databind problem by:Agnes
| myTab control got 2 pages, in page1, i need to type in customer code, and the customer information will be displayed in page 1 & page2. I am using databinding to move the record position. Before bmCustomer.addnew() . Everything goes fine, I can see the data in both Page2. However, after bmCustomer.addnew(), I type a customer code, [the back end store procedure will query that code and the return a datarow ] [In page 1] Me.txtCustAdd1.text = drCust(..... etc) <-- works fine and i can see the data [in page2] Me.txtCustInform.text = drCust(....etc) <- i can't see the data in page 2.
I use messagebox to test the page2 data, it return a correct value. BUT EVERY THING IN PAGE 2 is blank , why ?? I add 'Me.Tab2.refresh()' it seems useless. if I cut the textbox Me.txtCustInform.text from page2 and then paste in page1. It displays very well. What happend about Tab page2 ???
FromAgnes
| | | Reply: by:Cor Ligthert
| | | Hi Agnes,
You have placed this message before and got no answer, which mostly mean that your question is to complex, by adding more you do not get more answers, I think that you get more answers when you try to bring it back to the essentials and than do it step by step.
Just my thought Cor
will
| | | Reply: by:Agnes
| | | Dear Cor Agree with U , I am so tired and worry to switch our system from VFP to VB.Net. I need to perform the same basic features from vfp application to vb.net and I found it is a harsh task. I will try to check it again. Btw, I listen to your advice and normalize the tables which under 100 fields, using the most simple way (data adapter) to insert the data. Now, it is sucessfuly to update / insert the record.
Thanks for your kind help. From Agnes p.s- I am vfp developer in Hong Kong , sorry for my poor english
| | | Reply: by:Cor Ligthert
| | | Hi Agnes,
Every time you go further in dotNet, you see that you did it yesterday in a stupid way. There are so much classes that there is always a better way.
However, I hear now that you are making much progress and that is great.
Do not say sorry for your English, most visitors and I think 50% of the regulars are not from native English speaking countries.
There is nobody who says something about some ones English in this newsgroup or does not answer a question because of that
Cor
|
Posted by Xander Zelders
Populating initial Combobox display text
Found the following interesting discussion in the Newsgroups:
Populating initial Combobox display text by:Keith
| Hello - this started out as a minor annoyance - and now is starting to bother me more and more - I'm hoping someone can help me.
I would like to have a combobox display - NOT initially be blank - but contain a value. However the value is just for user reference - not really one of the combobox choices. For example intially the combobox should equal the word Select - and the item values can be say 'one', 'two', and 'three'.
I tried just typing in the text value - in the properties of the combobox control/object - but that did not work. Someone told me in order to display the value - it has to be an existing part of the collection. Doesn't completely make sense to me - because why have a Text properties field of the control - if you can't use it (everytime you fill something in - and leave that field - it's blanked out)
So what I ended up doing was - adding the item to the: Windows Form Designer Generated Code Section - something like this:
Me.ComboBox1.Items.Add("Select") Me.ComboBox1.Items.Add("one") Me.ComboBox1.Items.Add("two") Me.ComboBox1.Items.Add("three") Me.ComboBox1.Location = New System.Drawing.Point (8, 25) Me.ComboBox1.Size = New System.Drawing.Size(220, 22) Me.ComboBox1.Text = "Select"
Well - it works - but here's the real problem. Every now and then (I think when I click on that combobox - or even on the form somehow - to open the design) - it removes the last line: Me.ComboBox1.Text = "Select".
So - sometimes I compile - and I get "Select" as the initial default value for the combobox and other times - I do not and I have to re-add it. Sure - minor annoyance - but when you have to do this 10, 20, 30, 50 times - it becomes a MAJOR annoyance.
Am I doing something wrong? Can someone suggest a better way? Thank you.
| | | Reply: by:SStory
| | | Sounds like you are trying to do a webpage type thing of having a value that isn't in the list.
Looks like to me that if the style of the combobox is such that you can edit the text, setting the text property should be allowed?
Of course if the style is one of the other types it of course won't let you do this. Have you tried it with the correct style?
Shane
| | | Reply: by:Cor Ligthert
| | | HI Keith,
I think that your problem has to do with one of the few documentated on MSDE documented bugs in the combobox.
However even beside that I think this would be a better solution for you problem (I made this sample for you so you have to try it).
I hope this helps?
Cor \\Private Sub Form1_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Me.ComboBox1.SelectedIndex = 0 Me.ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList End Sub Private Sub ComboBox1_SelectedIndexChanged _ (ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles _ ComboBox1.SelectedIndexChanged If Me.ComboBox1.Text <> "Select" Then 'do something End If Me.ComboBox1.SelectedIndex = 0 End Sub ///
| | | Reply: by:Keith
| | | Cor,
thanks for you code - I tried it - but didn't get the results I expected. Perhaps I did not accurately state what I was attempting to do. I wanted to have the Select text appear - as the initial text of the Combobox - and then once the person clicked on any of the choices (besides Select) - the Select code would disappear. I ended up doing it in the following manner: (just curious - you mention this combobox bug is well know - any idea when anyone will "fix" it?)
Keep in mind this code is out there - but it works... The Combobox Collection is populated with the following entries: Select, One, and Two Declare a public variable: Public firsttimeonlycounter As Integer = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ComboBox1.Text = "Select" End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged If firsttimeonlycounter <> 1 And ComboBox1.SelectedItem <> "Select" Then ComboBox1.Items.Remove("Select") firsttimeonlycounter = 1 End If End Sub
Thanks again.
annoyance -
| | | Reply: by:Cor Ligthert
| | | Hi Keith,
I thought that the problem was that you did want keep the "Select", because standard when you set in the loadevent (or in the text in the designer) combobox.text = "Select" that is only showed once
:-)
Cor
|
Posted by Xander Zelders
Can some one please look at this code and see if there is a better way?
Found the following interesting discussion in the Newsgroups:
Can some one please look at this code and see if there is a better way? by:William Morgan
| this is the code for a uuedecode function.. it works but is kinda slow is there a better way in .net?
thanks for looking.. Private Function DecodeString(ByVal InString As String, ByVal Bytes As Long) As String Dim OutString As String Dim i As Long Dim x0, x1, x2 As Long 'These are the chars that will be spit out Dim y0, y1, y2, y3 As Long 'These are what we got in
Try For i = 1 To Len(InString) Step 4 y0 = Asc(Mid(InString, i, 1)) 'Get 4 chars and put into 'y's y1 = Asc(Mid(InString, i + 1, 1)) y2 = Asc(Mid(InString, i + 2, 1)) y3 = Asc(Mid(InString, i + 3, 1))
If (y0 = 96) Then y0 = 32 'If char is 96 then set to 2 If (y1 = 96) Then y1 = 32 If (y2 = 96) Then y2 = 32 If (y3 = 96) Then y3 = 32
x0 = ((y0 - 32) * 4) + ((y1 - 32) \ 16) 'Calculate the 3 chars x1 = ((y1 Mod 16) * 16) + ((y2 - 32) \ 4) x2 = ((y2 Mod 4) * 64) + (y3 - 32)
OutString = OutString + Chr(x0) + Chr(x1) + Chr(x2) Next i If Len(OutString) > Bytes Then DecodeString = Microsoft.VisualBasic.Left(OutString, Bytes)
Else DecodeString = OutString End If Catch ex As Exception End Try Return DecodeString End Function
| | | Reply: by:Jay B. Harlow [MVP - Outlook]
| | | William, A number of potential performance problems.
1. Use of Asc & Chr. Asc & Chr will cause the character to be encoded & decoded from the current ANSI code page (as defined under Windows). I would use AscW & ChrW and leave the characters as Unicode. I would ensure that when I read the string it used the proper System.TextEncoding object to ensure that the characters were all
2. Use of Mid, I would use String.Chars property instead, as you simply want a single char (in sets of 4).
3. Use of string Concatenation, I would use a StringBuilder instead.
4. I would consider using the shift operators over multiple & divide.
5. Use of Long variables, I would use Integer (a 32-bit value) unless I specifically needed a Long (a 64-bit value).
Something like (untested, syntax checked only):
Private Shared Function DecodeString(ByVal InString As String, ByVal Bytes As Integer) As String Dim OutString As New System.Text.StringBuilder(InString.Length * 3 4) Dim x0, x1, x2 As Integer 'These are the chars that will be spit out Dim y0, y1, y2, y3 As Integer 'These are what we got in
For i As Integer = 0 To Len(InString) - 1 Step 4 y0 = AscW(InString.Chars(i)) 'Get 4 chars and put into 'y's y1 = AscW(InString.Chars(i + 1)) y2 = AscW(InString.Chars(i + 2)) y3 = AscW(InString.Chars(i + 3))
If (y0 = 96) Then y0 = 32 'If char is 96 then set to 2 If (y1 = 96) Then y1 = 32 If (y2 = 96) Then y2 = 32 If (y3 = 96) Then y3 = 32
x0 = ((y0 - 32) << 2) + ((y1 - 32) >> 4) 'Calculate the 3 chars
x1 = ((y1 Mod 16) << 4) + ((y2 - 32) >> 2)
x2 = ((y2 Mod 4) << 6) + (y3 - 32)
OutString.Append(ChrW(x0)) OutString.Append(ChrW(x1)) OutString.Append(ChrW(x2)) Next i If OutString.Length > Bytes Then OutString.Length = Bytes End If Return OutString.ToString() End Function
Hope this helps Jay
| | | Reply: by:Cor Ligthert
| | | Hi William,
In addition to the complete answer from Jay, I think that it will be good to look as well to the "string.substring" it can be a very handy method in what you are doing.
Cor
| | | Reply: by:William Morgan
| | | thanks jay your code does work much better.
|
Posted by Xander Zelders
How to do this? EmailMessage.ValidateAddress = false
Found the following interesting discussion in the Newsgroups:
How to do this? EmailMessage.ValidateAddress = false by:Miguel Dias Moura
| Hello,
when i uploaded my web site to a server i got this message everytime there w |
| |