|
I'm not sure if this is the correct area, forgive me if it is not!
I have this datagrid that is called deleteCourseGrid and it has a template column. I put a checkbox inside and its ID is deleteCheck.
I also have a confirm button that runs the code below.
The problem is, somehow, it does not detect that a box is checked. I tried checking each individual rows and cb.checked is always false.
Am I doing something wrong?
Thanks for help in advance!
Dim connection As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))<br />
Dim command As New SqlCommand("delete from course where courseID = @courseID", connection)<br />
Dim i As Integer = 0<br />
Dim cb As CheckBox<br />
Dim courseID As String<br />
cb = deleteCourseGrid.Items(i).FindControl("deleteCheck")<br />
For i = 0 To deleteCourseGrid.Items.Count - 1<br />
If cb.Checked = True Then<br />
courseID = deleteCourseGrid.Items(i).Cells(0).Text<br />
command.Parameters.Add("@courseID", courseID)<br />
connection.Open()<br />
command.ExecuteNonQuery()<br />
connection.Close()<br />
End If<br />
Next<br />
Response.Redirect("updated.aspx")
|
|
|
|
|
try treating cells in that column as bools
<br />
If row.item("deleteCheck") then<br />
Delete<br />
End if<br />
|
|
|
|
|
Hi! Thanks for the help.
But I'm really not sure what you mean. Could you elaborate?
Thanks!
|
|
|
|
|
well your normal textbox data column in the grid, displays all strings and numbers as text. It works the same for boolean columns. A DataGridBoolColumn will display true as checked, false as unchecked. So whatever column on your datatable is mapped to this DataGridBoolColumn will contain the true or false that is shown in the datagrid column.
If you had a datatable (Two columns -> Name, Smoker) where smoker would be mapped to the DataGridBoolColumn, in each row in the table, a boolean would appear in the column smoker with resepct to the checked state of the textbox on the datagrid.
Hope that helps.
|
|
|
|
|
Thanks Kevin.
I think understand the logic behind your explanation, however I fail to find anything that relates DataGridBoolColumn in Visual Studio 2003.
Is there something that I'm missing?
What I'm trying to do is to allow the administrator to tick the courses that he wants to delete and then when he clicks the confirm button, the code scrolls through, if it's ticked, it sends the SQL command and deletes it.
I'm sorry for troubling you =/
|
|
|
|
|
ok This is how I would do that. Lets say you have a datatable (courseTable) with one column (A course ID).
First add a second column to the table
<br />
courseTable.columns.add(new dataColumn("Delete"))<br />
Setup the tablestyle for the bool column
<br />
Dim style As New DataGridTableStyle<br />
style.GridColumnStyles.Clear()<br />
style.MappingName = courseTable.TableName<br />
<br />
Dim col As New DataGridBoolColumn<br />
col.MappingName = "Delete"<br />
col.HeaderText = "Delete"<br />
col.AllowNull = False<br />
style.GridColumnStyles.Add(col)<br />
<br />
DataGrid1.TableStyles.Add(style)<br />
DataGrid1.DataSource = courseTable<br />
now you have the right setup for the bool column, just display it by adding rows to the datatable somehow from the database.
so in your confirm button routine just check for deletes
<br />
For Each row As DataRow In courseTable.Rows<br />
If row.Item("Delete") Then<br />
'This row was ticked so perform a delete<br />
End If<br />
Next<br />
That should do it for you
|
|
|
|
|
I'm trying this out and I have a strong feeling that it will help with my problem.
However, I am stuck at trying to dim a new DataGridTableStyle. Is this not available in The .Net 1.1 framework or something? Visual Studio 2003 says that Type DataGridTableStyle is not defined.
I tried reading http://msdn.microsoft.com/msdnmag/issues/03/08/DataGrids/default.aspx#S6 and it talks about DataGridTableStyle, yet visual studio does not seem to recognise this.
What should I do? And a million thanks for your many replies!
|
|
|
|
|
DataGridTableStyle is valid in windows application.
but you are working in web applications that why you are getting it and it is giving errors.
anyways next time post your questions in asp.net forum....you have currently posted this question in vb.net ..............thats why the person has misunderstood the scenario and he has given this answer.....anyways it happens..
hope you have found solution to your problem.
Regards,
Kapil Thakur
(Where's there is Kapil , there is a way) - thakur.kapil@gmail.com
|
|
|
|
|
hi,
you are currently taking the checked value as string. Instead of it, take it as a boolean variable.
i m using your code and the changes are reflected in BOLD text.
Dim cb As BOOLEAN
Dim courseID As boolean
cb = CTYPE(deleteCourseGrid.Items(i).FindControl("deleteCheck"), CHECKBOX).CHECKED
For i = 0 To deleteCourseGrid.Items.Count - 1
IF cb = TRUE THEN
courseID = deleteCourseGrid.Items(i).Cells(0).Text
command.Parameters.Add("@courseID", courseID)
connection.Open()
command.ExecuteNonQuery()
connection.Close()
End If
use this and your code will work fine.
ALSO check that you are reloading the datagrid on page_load
Regards,
Kapil Thakur
(Where's there is Kapil , there is a way) - thakur.kapil@gmail.com
|
|
|
|
|
Hi!
Thanks for the help!!
I tried your way, however it does not work.
I've been stepping the program through and the problem lies with the fact that it is somehow ignoring boxes that are checked.
So it keeps looping to If cb = true then and then skipping the entire code within and just stepping over to End If
This is really confusing =/
|
|
|
|
|
hi,
first of all make sure that before checking the checkboxes values....you are not reloading the datagrid with data again.
make sure that after clicking the button you are loading the data again at some point in your code.....as this is the most common mistake in such scenarios.
so, be sure that the grid is not reloaded with data.
anyways.......
i m attaching a thoroughly tested and working code snippet.
Dim count As Integer = 0
For count = 0 To dgUser.Items.Count - 1
Dim IsChecked As String = CType(dgUser.Items(count).FindControl("chkDeleteUser"), CheckBox).Checked.ToString()
If UCase(Trim(IsChecked)) = UCase(Trim("True")) Then
''IGNORE THE FOLLOWING If-EndIf block - starting here
'If UCase(Trim(Session("userid"))) = UCase(Trim(dgUser.Items(count).Cells(1).Text.ToString)) Then
'ErrorLabel.Visible = True
'ErrorLabel.Text = Session("oRM").GetString("UD_You_Are_Not_Allowed_To_Delete_Your_Own_Data") & " - " & dgUser.Items(count).Cells(3).Text.ToString
'pnlGrid.Visible = True
'pnlAddUser.Visible = False
'Exit Sub
'End If
''IGNORE THE FOLLOWING If-EndIf block - ending here
End If
Next
if even this is not working......then my dear frnd , send ur project to me...i'll be glad to help you out by debuging it and fixing your problem
my email id is thakur.kapil@gmail.com
Regards,
Kapil Thakur
(Where's there is Kapil , there is a way) - thakur.kapil@gmail.com
|
|
|
|
|
i have this class below which i'm using to uniquely generate a set of numbers. What it does is if i want 10 numbers randomly selected out of 11 i will pass it as a parameter to it and it'll return me the unique numbers. i dont want repetitions of the same number and it does what i want exactly... the problem is that atimes it gets into an infinite loop especially when i want 4 out of 5 or 3 out of 4.
the class
Public Class UniqueNumbers
Dim randCtr As New Random
Public Function genNumbers(ByVal totalNeeded As Integer, ByVal AvailableRange As Integer) As Integer()
Dim var1, var3 As Integer
Dim generatedNumbers(totalNeeded - 1) As Integer
Dim returnedNumbers(totalNeeded - 1) As Integer
For var1 = 0 To (totalNeeded - 1)
generatedNumbers(var1) = randCtr.Next(1, (AvailableRange + 1))
returnedNumbers(var1) = generatedNumbers(var1)
naa: For var3 = 0 To var1
If returnedNumbers(var3) = generatedNumbers(var1) Then
generatedNumbers(var1) = randCtr.Next(1, (AvailableRange + 1))
If var1 <> 0 Then
'varar(var1) = vararr(var1)
GoTo naa
End If
End If
Next
returnedNumbers(var1) = generatedNumbers(var1)
Next
genNumbers = returnedNumbers
Return genNumbers
End Function
End Class
all that i mean is if i want 3 out of 4
it can return 123 or 321 or 231 anything other than repeating one number twice like 112 or 122 or 332. My main problem is i want it to be faster and atimes it gets into a hang or infinite loop. Help me out guys.
Love makes the world go round
|
|
|
|
|
I can very well imagine that your code goes into an eternal loop, it's rather buggy. For example, the first random number created for each position in the array will always be replaced by a new random number, as you regard it as a duplicate as it is equal to itself. Also, if a number is the same as the first in the array, you pick a new number and accept it without checking if the new number is the same as the first in the array.
Perhaps not the most efficient, but very simple and straight forward:
Put all the possible numbers in a list. Pick one of them by random and remove it from the list. Repeat until you have the desired number of numbers.
---
b { font-weight: normal; }
|
|
|
|
|
vb.net: when i click into a datagrid, the text becomes blue, the background gray, a cursor appears, and formatting for that cell disappears.
but i want nothing at all to happen, when i click in a cell. no cursor, no change of color. how can i do that?
|
|
|
|
|
one possible solution would be to capture the datagrid's mouse up event and then select some other control such as a blank label or soemthing
<br />
Private Sub datagrid_MouseUp(ByVal sender As Object, _<br />
ByVal e As System.Windows.Forms.MouseEventArgs) Handles dtgCategory.MouseUp<br />
label.Select()<br />
End Sub<br />
|
|
|
|
|
thanks, didn't think about that myself.
i thought about something like overriding the selection of the grid cell somehow, but i didn't know, how to do.
but this should be fine for me. thanks.
|
|
|
|
|
i have this project which i need to finish in the next week or so. the project is a version of notepad in vb.net, so far everything is ok but when you run the programme the design does not show in the form and i dont know why. so if any one of you geniuses can help me i would be eternally grateful.
heres the code:
Imports System
Imports System.IO
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Namespace notepad
_
Public Class Form1
Inherits System.Windows.Forms.Form
Private components As System.ComponentModel.IContainer
Private pageSetupDialog1 As System.Windows.Forms.PageSetupDialog
Private WithEvents menuItem_color As System.Windows.Forms.MenuItem
Private colorDialog1 As System.Windows.Forms.ColorDialog
Private fontDialog1 As System.Windows.Forms.FontDialog
Private openFileDialog1 As System.Windows.Forms.OpenFileDialog
Private printDialog1 As System.Windows.Forms.PrintDialog
Private saveFileDialog1 As System.Windows.Forms.SaveFileDialog
Private statusBar1 As System.Windows.Forms.StatusBar
Private WithEvents textBox_pad As System.Windows.Forms.TextBox
Private menuItem4 As System.Windows.Forms.MenuItem
Private WithEvents menuItem_font As System.Windows.Forms.MenuItem
Private WithEvents menuItem_wordwrap As System.Windows.Forms.MenuItem
Private WithEvents menuItem_tmdt As System.Windows.Forms.MenuItem
Private WithEvents menuItem_selectAll As System.Windows.Forms.MenuItem
Private menuItem6 As System.Windows.Forms.MenuItem
Private menuItem1 As System.Windows.Forms.MenuItem
Private WithEvents menuItem_del As System.Windows.Forms.MenuItem
Private WithEvents menuItem_paste As System.Windows.Forms.MenuItem
Private WithEvents menuItem_copy As System.Windows.Forms.MenuItem
Private WithEvents menuItem_cut As System.Windows.Forms.MenuItem
Private WithEvents menuItem_undo As System.Windows.Forms.MenuItem
Private menuItem13 As System.Windows.Forms.MenuItem
Private WithEvents menuItem_exit As System.Windows.Forms.MenuItem
Private WithEvents menuItem_print As System.Windows.Forms.MenuItem
Private WithEvents menuItem_pagesetup As System.Windows.Forms.MenuItem
Private WithEvents menuItem_saveas As System.Windows.Forms.MenuItem
Private WithEvents menuItem_save As System.Windows.Forms.MenuItem
Private WithEvents menuItem_open As System.Windows.Forms.MenuItem
Private WithEvents menuitem_new As System.Windows.Forms.MenuItem
Private menuItem_format As System.Windows.Forms.MenuItem
Private menuItem_edit As System.Windows.Forms.MenuItem
Private menuItem_file As System.Windows.Forms.MenuItem
Private mainMenu1 As System.Windows.Forms.MainMenu
Public Sub New()
InitializeComponent()
End Sub 'New
Protected Overloads Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub 'Dispose
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Me.pageSetupDialog1 = New System.Windows.Forms.PageSetupDialog
Me.menuItem_print = New System.Windows.Forms.MenuItem
Me.menuItem_pagesetup = New System.Windows.Forms.MenuItem
Me.colorDialog1 = New System.Windows.Forms.ColorDialog
Me.menuItem_wordwrap = New System.Windows.Forms.MenuItem
Me.menuItem_tmdt = New System.Windows.Forms.MenuItem
Me.menuItem_paste = New System.Windows.Forms.MenuItem
Me.menuItem_saveas = New System.Windows.Forms.MenuItem
Me.menuItem_file = New System.Windows.Forms.MenuItem
Me.menuitem_new = New System.Windows.Forms.MenuItem
Me.menuItem_open = New System.Windows.Forms.MenuItem
Me.menuItem_save = New System.Windows.Forms.MenuItem
Me.menuItem4 = New System.Windows.Forms.MenuItem
Me.menuItem13 = New System.Windows.Forms.MenuItem
Me.menuItem_exit = New System.Windows.Forms.MenuItem
Me.menuItem_cut = New System.Windows.Forms.MenuItem
Me.menuItem_selectAll = New System.Windows.Forms.MenuItem
Me.mainMenu1 = New System.Windows.Forms.MainMenu(Me.components)
Me.menuItem_edit = New System.Windows.Forms.MenuItem
Me.menuItem_undo = New System.Windows.Forms.MenuItem
Me.menuItem1 = New System.Windows.Forms.MenuItem
Me.menuItem_copy = New System.Windows.Forms.MenuItem
Me.menuItem_del = New System.Windows.Forms.MenuItem
Me.menuItem6 = New System.Windows.Forms.MenuItem
Me.menuItem_format = New System.Windows.Forms.MenuItem
Me.menuItem_font = New System.Windows.Forms.MenuItem
Me.menuItem_color = New System.Windows.Forms.MenuItem
Me.menuItem_Aboutme = New System.Windows.Forms.MenuItem
Me.statusBar1 = New System.Windows.Forms.StatusBar
Me.textBox_pad = New System.Windows.Forms.TextBox
Me.fontDialog1 = New System.Windows.Forms.FontDialog
Me.openFileDialog1 = New System.Windows.Forms.OpenFileDialog
Me.saveFileDialog1 = New System.Windows.Forms.SaveFileDialog
Me.printDialog1 = New System.Windows.Forms.PrintDialog
Me.SuspendLayout()
'
'menuItem_print
'
Me.menuItem_print.Index = 6
Me.menuItem_print.Shortcut = System.Windows.Forms.Shortcut.CtrlP
Me.menuItem_print.Text = "Print..."
'
'menuItem_pagesetup
'
Me.menuItem_pagesetup.Index = 5
Me.menuItem_pagesetup.Text = "Page Setup..."
'
'menuItem_wordwrap
'
Me.menuItem_wordwrap.Index = 0
Me.menuItem_wordwrap.Text = "Word Wrap"
'
'menuItem_tmdt
'
Me.menuItem_tmdt.Index = 8
Me.menuItem_tmdt.Shortcut = System.Windows.Forms.Shortcut.F5
Me.menuItem_tmdt.Text = "Time/Date"
'
'menuItem_paste
'
Me.menuItem_paste.Index = 4
Me.menuItem_paste.Text = "Paste Ctrl+V"
'
'menuItem_saveas
'
Me.menuItem_saveas.Index = 3
Me.menuItem_saveas.Text = "Save As..."
'
'menuItem_file
'
Me.menuItem_file.Index = 0
Me.menuItem_file.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuitem_new, Me.menuItem_open, Me.menuItem_save, Me.menuItem_saveas, Me.menuItem4, Me.menuItem_pagesetup, Me.menuItem_print, Me.menuItem13, Me.menuItem_exit})
Me.menuItem_file.Text = "File"
'
'menuitem_new
'
Me.menuitem_new.Index = 0
Me.menuitem_new.Shortcut = System.Windows.Forms.Shortcut.CtrlN
Me.menuitem_new.Text = "New"
'
'menuItem_open
'
Me.menuItem_open.Index = 1
Me.menuItem_open.Shortcut = System.Windows.Forms.Shortcut.CtrlO
Me.menuItem_open.Text = "Open"
'
'menuItem_save
'
Me.menuItem_save.Index = 2
Me.menuItem_save.Shortcut = System.Windows.Forms.Shortcut.CtrlS
Me.menuItem_save.Text = "Save..."
'
'menuItem4
'
Me.menuItem4.Index = 4
Me.menuItem4.Text = "-"
'
'menuItem13
'
Me.menuItem13.Index = 7
Me.menuItem13.Text = "-"
'
'menuItem_exit
'
Me.menuItem_exit.Index = 8
Me.menuItem_exit.Text = "Exit"
'
'menuItem_cut
'
Me.menuItem_cut.Index = 2
Me.menuItem_cut.Text = "Cut Ctrl+X"
'
'menuItem_selectAll
'
Me.menuItem_selectAll.Index = 7
Me.menuItem_selectAll.Shortcut = System.Windows.Forms.Shortcut.CtrlA
Me.menuItem_selectAll.Text = "Select All"
'
'mainMenu1
'
Me.mainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuItem_file, Me.menuItem_edit, Me.menuItem_format, Me.menuItem_Aboutme})
'
'menuItem_edit
'
Me.menuItem_edit.Index = 1
Me.menuItem_edit.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuItem_undo, Me.menuItem1, Me.menuItem_cut, Me.menuItem_copy, Me.menuItem_paste, Me.menuItem_del, Me.menuItem6, Me.menuItem_selectAll, Me.menuItem_tmdt})
Me.menuItem_edit.Text = "Edit"
'
'menuItem_undo
'
Me.menuItem_undo.Index = 0
Me.menuItem_undo.Text = "Undo Ctrl+Z"
'
'menuItem1
'
Me.menuItem1.Index = 1
Me.menuItem1.Text = "-"
'
'menuItem_copy
'
Me.menuItem_copy.Index = 3
Me.menuItem_copy.Text = "Copy Ctrl+C"
'
'menuItem_del
'
Me.menuItem_del.Index = 5
Me.menuItem_del.Text = "Delete Del"
'
'menuItem6
'
Me.menuItem6.Index = 6
Me.menuItem6.Text = "-"
'
'menuItem_format
'
Me.menuItem_format.Index = 2
Me.menuItem_format.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuItem_wordwrap, Me.menuItem_font, Me.menuItem_color})
Me.menuItem_format.Text = "Format"
'
'menuItem_font
'
Me.menuItem_font.Index = 1
Me.menuItem_font.Text = "Font..."
'
'menuItem_color
'
Me.menuItem_color.Index = 2
Me.menuItem_color.Text = "Color..."
'
'menuItem_Aboutme
'
Me.menuItem_Aboutme.Index = 3
Me.menuItem_Aboutme.Text = "About me"
'
'statusBar1
'
Me.statusBar1.Location = New System.Drawing.Point(0, 233)
Me.statusBar1.Name = "statusBar1"
Me.statusBar1.Size = New System.Drawing.Size(330, 20)
Me.statusBar1.TabIndex = 2
Me.statusBar1.Text = "05172411"
'
'textBox_pad
'
Me.textBox_pad.Dock = System.Windows.Forms.DockStyle.Fill
Me.textBox_pad.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!)
Me.textBox_pad.HideSelection = False
Me.textBox_pad.Location = New System.Drawing.Point(0, 0)
Me.textBox_pad.Multiline = True
Me.textBox_pad.Name = "textBox_pad"
Me.textBox_pad.ScrollBars = System.Windows.Forms.ScrollBars.Both
Me.textBox_pad.Size = New System.Drawing.Size(330, 253)
Me.textBox_pad.TabIndex = 1
'
'saveFileDialog1
'
Me.saveFileDialog1.FileName = "doc1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(330, 253)
Me.Controls.Add(Me.statusBar1)
Me.Controls.Add(Me.textBox_pad)
Me.Menu = Me.mainMenu1
Me.Name = "Form1"
Me.Text = "Untiteled-Notepad"
Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub 'InitializeComponent
Protected Sub menuItem_wordwrap_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_wordwrap.Click
If textBox_pad.WordWrap = True Then
textBox_pad.WordWrap = False
Else
textBox_pad.WordWrap = True
End If
End Sub 'menuItem_wordwrap_Click
Protected Sub menuItem_Aboutme_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim note As MessageBox
MessageBox.Show("05172411")
End Sub 'menuItem_aboutpad_Click
Protected Sub menuItem_del_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_del.Click
textBox_pad.SelectedText = ""
End Sub 'menuItem_del_Click
Protected Sub textBox_pad_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles textBox_pad.TextChanged
If textBox_pad.SelectedText = "" Then
menuItem_cut.Enabled = True
menuItem_copy.Enabled = True
menuItem_del.Enabled = True
Else
menuItem_cut.Enabled = False
menuItem_copy.Enabled = False
menuItem_del.Enabled = False
End If
End Sub 'textBox_pad_TextChanged
Protected Sub menuItem_paste_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_paste.Click
textBox_pad.Paste()
End Sub 'menuItem_paste_Click
Protected Sub menuItem_copy_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_copy.Click
textBox_pad.Copy()
End Sub 'menuItem_copy_Click
Protected Sub menuItem_cut_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_cut.Click
textBox_pad.Cut()
End Sub 'menuItem_cut_Click
Protected Sub menuItem_undo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_undo.Click
textBox_pad.Undo()
End Sub 'menuItem_undo_Click
Protected Sub menuItem_pagesetup_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_pagesetup.Click
Dim doc As New System.Drawing.Printing.PrintDocument()
doc.DocumentName = textBox_pad.Text
pageSetupDialog1.Document = doc
pageSetupDialog1.ShowDialog()
End Sub 'menuItem_pagesetup_Click
Protected Sub menuItem_color_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_color.Click
colorDialog1.ShowDialog()
textBox_pad.ForeColor = colorDialog1.Color
End Sub 'menuItem_color_Click
Protected Sub menuItem_font_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_font.Click
fontDialog1.ShowDialog()
textBox_pad.Font = fontDialog1.Font
End Sub 'menuItem_font_Click
Protected Sub menuItem_print_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_print.Click
printDialog1.AllowPrintToFile = True
Dim doc As New System.Drawing.Printing.PrintDocument()
doc.DocumentName = textBox_pad.Text
printDialog1.Document = doc
printDialog1.ShowDialog()
doc.Print()
End Sub 'menuItem_print_Click
Protected Sub menuItem_selectAll_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_selectAll.Click
textBox_pad.SelectAll()
End Sub 'menuItem_selectAll_Click
Protected Sub menuItem_tmdt_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_tmdt.Click
textBox_pad.Text = textBox_pad.Text + DateTime.Now.ToLongTimeString() + DateTime.Now.ToLongDateString()
End Sub 'menuItem_tmdt_Click
Protected Sub menuItem_saveas_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_saveas.Click
saveFileDialog1.ShowDialog()
Dim name As String = saveFileDialog1.FileName
Dim value1 As String = textBox_pad.Text
Dim sout As New StreamWriter(name)
sout.WriteLine(value1)
sout.Flush()
Me.Text = name
sout.Close()
End Sub 'menuItem_saveas_Click
Protected Sub menuitem_new_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuitem_new.Click
textBox_pad.Text = ""
Me.Text = "Untiteled-Notepad"
End Sub 'menuitem_new_Click
Protected Sub menuItem_exit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_exit.Click
Me.Close()
End Sub 'menuItem_exit_Click
Protected Sub menuItem_save_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_save.Click
Dim name As String
Dim value1 As String = textBox_pad.Text
If Me.Text = "Untiteled-Notepad" Then
saveFileDialog1.ShowDialog()
name = saveFileDialog1.FileName
Else
name = Me.Text
End If
Dim sout As New StreamWriter(name)
sout.WriteLine(value1)
sout.Flush()
Me.Text = name
sout.Close()
End Sub 'menuItem_save_Click
Protected Sub menuItem_open_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem_open.Click
openFileDialog1.ShowDialog()
Dim name As String = openFileDialog1.FileName
Dim contain As System.IO.Stream = openFileDialog1.OpenFile()
Dim m_streamReader As New StreamReader(contain)
Dim str As String = ""
Dim check As Integer
check = m_streamReader.Read()
While check <> -1
str = str + Microsoft.VisualBasic.ChrW(check)
check = m_streamReader.Read()
End While
textBox_pad.Text = str
Me.Text = name
contain.Close()
End Sub 'menuItem_open_Click
'Entry point which delegates to C-style main Private Function
' Public Overloads Shared Sub Main()
' Main(System.Environment.GetCommandLineArgs())
' End Sub
Public Overloads Shared Sub Main(ByVal args() As String)
Application.Run(New Form1())
End Sub
Friend WithEvents menuItem_Aboutme As System.Windows.Forms.MenuItem 'Main
End Class 'Form1
End Namespace 'notepad
and as you will have noticed vb.net is definately not my strong point THANK YOU
Luna Harp
|
|
|
|
|
I've repaired ur project. Couldn't figure out why it didnt work. SO I created a new project I started to paste ur code. I got it working.
You still have some problems to correct to it but I guess u know it already and I dont think that u'll have any problem to correct them.
I can send you a zip with the new project on ur email address.
You can respond at: ludo.deraed@fox.com
I'll explain you in details why it could't show the components.
-- modified at 10:01 Tuesday 5th December, 2006
Ludo
|
|
|
|
|
Dear friends...
ı had written a code at Wincc...Its
dim box as integer
dim fener
Set fener=ScreenItems("lorry")
...
for box=1 to 5
Fener.left=Fener.left-10
next
end function
...
but editor says its wrong...
so whats the differ VBS and Visual Basic 6
|
|
|
|
|
First, what is "Wincc"?
Next, what's the error that you're getting and on which line?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dear Kreskowiak
Wincc is a type of automation programme..It's of Sıemens....We use it for communicate PLC-COMPUTER and another electric and electronic devices....In that programme u draw some electrical devices and then u write some codes for give them moveable actions..
i show u a example picture from it..
http://www.resimekle.com/yukle/view/91764
|
|
|
|
|
How to read data from excel sheet
and how to insert it into microsoft sqlserver 2000.
|
|
|
|
|
|
i have tried much on for sorting a simple datagrid but yup!
Dim DV As DataView
Dim ds1 As DataSet
DV = ds1.Tables("tbl_emps").DefaultView
Me.DataGrid1.DataSource() = DV
Me.DataGrid1.DataBind()
this is the code what i have written..
the error is :
Object reference not set to an instance of an object.
can anyone help me out please
tirumal
|
|
|
|
|
Does anybody knows how to play an swf file inside a .NET form.
I tried to use the flash ocx component but it says failed to load activeX.
Is there any other means?
Thanks in advance,
Phil
|
|
|
|
|