|
ok, but at least is It easy to know where the register is set to choose the sim for call?
|
|
|
|
|
Only through the SDK documentation on the phone.
I have no experience with it myself, but I at least know where'd I look for the information.
|
|
|
|
|
I have looked for an explanation to why the following code is resulting in the error
"Overload resolution failed because no 'SetSelectedCellCore' is accessible." on the line
dgvStudents.SetSelectedCellCore(0, 0, True)
I have no controls on my form. I am running Win7 and Visual Basic Express 2008, but i get the same result on my WinXP machine running VB Express 2008. Any help would be appreciated.
Imports System.Windows.Forms
Public Class Exercise
Dim dgvStudents As MyDataGridView = New MyDataGridView
Private Sub Exercise_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Text = "Students Records"
dgvStudents = New MyDataGridView()
dgvStudents.Location = New Point(12, 12)
dgvStudents.Size = New Size(650, 100)
Dim colFullName As DataGridViewColumn = New DataGridViewColumn
colFullName.Name = "FullName"
colFullName.HeaderText = "Full Name"
Dim celFullName As DataGridViewCell = New DataGridViewTextBoxCell
colFullName.CellTemplate = celFullName
dgvStudents.Columns.Add(colFullName)
Dim colPhone As DataGridViewColumn = New DataGridViewColumn
colPhone.Name = "PhNum"
colPhone.HeaderText = "Ph Number"
Dim celPhone As DataGridViewCell = New DataGridViewTextBoxCell
colPhone.CellTemplate = celPhone
dgvStudents.Columns.Add(colPhone)
Controls.Add(dgvStudents)
dgvStudents.SetSelectedCellCore(0, 0, True)
End Sub
End Class
Public Class MyDataGridView
Inherits DataGridView
Protected Overrides Sub SetSelectedCellCore( _
ByVal columnIndex As Integer, _
ByVal rowIndex As Integer, _
ByVal selected As Boolean)
MyBase.SetSelectedCellCore(columnIndex, rowIndex, selected)
End Sub
End Class
modified on Wednesday, May 12, 2010 1:46 PM
|
|
|
|
|
The overridden method remains protected and can only be accessed from within your MyDataGridView class. A public wrapper method would be needed to do what you want as the SetSelectedCellCore method's access modifier cannot be changed from protected to public.
Alan.
|
|
|
|
|
This is a protected method which means that you can't access it directly. AFAIK you can only access it from within the class.
Generally, the only time you would want to override this method was if you wanted to prevent a user from focusing on a particular cell.
Why not just do
dgvStudents.Rows(0).Cells(0).Selected = True
I would not suggest overriding a protected method to do something it's not meant to do...but...
you could just add a new method within your MyDataGridView class called something like MySetSelectedCellCore that simply calls your overridden SetSelectedCellCore . Then you just call that MySetSelectedCellCore . It would look like:
Public Class myDataGridView
Inherits DataGridView
Protected Overrides Sub SetSelectedCellCore(ByVal columnIndex As Integer, ByVal rowIndex As Integer, ByVal selected As Boolean)
MyBase.SetSelectedCellCore(columnIndex, rowIndex, selected)
End Sub
Public Sub MySetSelectedCellCore(ByVal columnIndex As Integer, ByVal rowIndex As Integer, ByVal selected As Boolean)
SetSelectedCellCore(columnIndex, rowIndex, selected)
End Sub
End Class
though again, I must stress, that's not what it was intended to do and not the best way to do what it looks like you are trying to do.
|
|
|
|
|
Thanks, both of you, for the pointers. I have learned a couple of different ways to do this now. I should be able to apply this to different objects as well.
|
|
|
|
|
Just as an FYI, when you call
dgvStudents.Rows(0).Cells(0).Selected = True the DataGridView implements this by making a call to SetSelectedCellCore You can see this by using the class you created as listed in your OP and setting a breakpoint on
MyBase.SetSelectedCellCore(columnIndex, rowIndex, selected) then calling
dgvStudents.Rows(0).Cells(0).Selected = True .
|
|
|
|
|
I did notice that, so I went searching for the reason that it worked... I did a little bit of VB6 as a hobby and wondered what could be so drastically different in vb.net. now i need to move a program I wrote in VB6 over to .net. I think I might like the new OOP paradigm, but only time will tell, and there's a little bit of a learning curve here.
|
|
|
|
|
hi
how to parse the Excel worksheet and write the data to a file using VBA Scripting ?
kindly provide me the tutorial to implement this task.
Thanks in Advance,
Narendra
|
|
|
|
|
Here is a snipet of VBA code that loops through a sheet and sets a cell value. (nothing really useful)
What it does show you is how you can loop through cells and get their values.
Hope this helps.
Sub DEMOscript()
'
Dim i As Integer
Dim r As Integer
r = MsgBox("This will clear the contents of Sheet1", vbOKCancel, "Confirm Processing")
If (r = 1) Then
Sheet1.Cells.Clear
totalrows = ActiveSheet.UsedRange.Rows.Count
For i = 2 To totalrows
Sheets("Sheet1").Cells(i, 2).Value = i
Next i
Else
MsgBox ("No processing performed.")
End If
End Sub
|
|
|
|
|
In addition to Davids snippet I would recommend you to use Intellisense as much as you can. It's easy, gives you some inspiration even while typing, and helps flatten your learning curve Let me give you an example:
If MsgBox("This will clear the contents of Sheet1", vbOKCancel, "Confirm Processing") = vbOK then ... instead of the (unnecessary) r variable shows you the possible results of the message box, so that you wouldn't have to guess the value.
|
|
|
|
|
|
How can I search all the files available on my computer (C,D,E,F...) drives like search functionality in windows.
The application should search the subfolder as well in the drives.
I want to have a list of all the files available in my computer.
Thanks In Advance
|
|
|
|
|
That's going to be slooow..
The recipe first;- List all drives (Google for a snippet)
- Create a recursive function to loop all folders in that drive
- Proces all files and folders that the function returns
ejaz_pk wrote: like search functionality in windows.
That one allows you to search "within" files, and is more complex then the recipe above. Do you want to "list" all your files, or do you want to search their contents?
I are Troll
|
|
|
|
|
I just want file names list and path of the files.
|
|
|
|
|
The hardest part would be the recursive funtion to scan the folders. There's an example on that over here[^], and also on the Knowledge Base[^].
The rest is up to you
I are Troll
|
|
|
|
|
Easily done by shelling to a DOS command that creates a text file, then parsing this if necessary:
The following DOS command will create a file called Output.txt with a list of all files (not including system or hidden) on drive c: - the /s recurses subdirectories, and the /b restricts the output to filename only.
DIR C: /s /b >Output.txt
====================================
Transvestites - Roberts in Disguise!
====================================
|
|
|
|
|
How to Redirect a LinkLabel from one window form to another window form in VB 2005?
|
|
|
|
|
form.show
or
form.ShowDialog
SOFTDEV
If you have knowledge, let others light their candles at it. [ Let's work to help developers, not make them feel stupid ]
|
|
|
|
|
Hi,everyone.I am hoping that the text that I input in the textbox can be captured in the
excel each sheet ,column 3, rows 2-20 for example.
Code like under,I think there are many errors in it,please tell me how to write it,please.
Thanks!
Imports Office = Microsoft.Office.Core
Imports Microsoft.Office.Interop.Excel
Private Sub OperateExcel()
Dim Xls As Object
Dim Xlsbook As Excel.Workbook
Dim Xlssheet As Excel.Worksheet
Dim Xlsrange As Excel.Range
Xls = CreateObject("excel.application")
Xlsbook = Xls.Workbooks.open("D:\text.xls")
Xls.Visible = True
Xlssheet = Xlsbook.Worksheets("sheet1")
For Each Xlssheet In Xls.Xlsbook
Xlsrange = Xlssheet.Range("H3")
Xlsrange.Value = txtProduct.Text
Xlsrange = Xlssheet.Range("H4")
Xlsrange.Value = txtName.Text
Xlsrange = Xlssheet.Range("H5")
Xlsrange.Value = txtNum.Text
Next
Xlsbook.Close()
Xls.Quit()
releaseObject(Xls)
releaseObject(Xlsbook)
releaseObject(Xlssheet)
End Sub
modified on Friday, May 7, 2010 1:12 AM
|
|
|
|
|
Where to start...
I am not exactly sure what you are trying to achieve, and I take it you assembled this code from examples, or copied it as is.
So let's start from the beginning. If you suspect that this code has errors, the first thing you should do is put all the code inside the sub into a try catch clause:
Private Sub OperateExcel()
Try
'the rest of the code here'
Catch ex as Exception
MsgBox(ex.tostring)
End Try
End Sub
Then at least you'll find out if this code works at all. After that comes the important part, comparing what this code does to what you want it to do.
A simple way to start is to write comments into the code. One comment for each step, and then fill in the code bits doing each step.
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hi,Johan,thanks for your suggestion.I apologize for the late reply...I used try catch clause in my code and then it told me an exception like this:
system.runtime.interop services.COMException(0x80020003):member not found.
it comes from:xlssheet = xlsworkbook.worksheet(1)
Could you give me suggestions to solve it?Thank you
modified on Saturday, May 8, 2010 9:35 PM
|
|
|
|
|
Hi sanyexian,
I changed your code a little bit so that it works. Still you might encounter many traps, since communication with Excel (i.e. COM / Office) can be very tricky sometimes. Also don't forget the small things, like making your assembly COM visible (project properties). You'll find tons of material about the issue here and in the web - and a lot is worth reading. Good luck
Sub OperateExcel()
' Compile with Option Strict Off to allow late binding.
Dim xlsApp As Object
Dim xlsBook As Object
Dim xlsSheet As Object
xlsApp = CreateObject("Excel.Application")
' Late bind an instance of an Excel workbook.
xlsBook = xlsApp.Workbooks.Add
' Late bind an instance of an Excel worksheet.
xlsSheet = xlsBook.Worksheets(1)
xlsSheet.Activate()
' Show the application.
xlsSheet.Application.Visible = True
For Each xlsSheet In xlsBook.worksheets
' put your text into the cells in a simpler way
xlsSheet.Range("H3").Value = "txtProduct"
xlsSheet.Range("H4").Value = "txtName"
xlsSheet.Range("H5").Value = "txtNum"
' A more useful way since you can iterate through rows/colums
' Here: Place some text in the second row of the sheet.
xlsSheet.Cells(2, 8) = "This is column H row 2"
Next
xlsBook.SaveAs("D:\text.xls")
xlsBook.Close()
xlsApp.Quit()
xlsSheet = Nothing
xlsBook = Nothing
xlsApp = Nothing
End Sub
|
|
|
|
|
How did that saying go again, about giving a man a fish...?
My advice is free, and you may get what you paid for.
|
|
|
|
|
You're surely right on one side. On the other side I've experienced so many other traps communicating with Office (and still do, as you know from my own thread ), that he will have to dig deeper for himself anyway. Probaly he even gets more motivated by having an easier start
|
|
|
|