|
Hi
i have form with some text boxes and grids on it now i want to handle key or shortcuts for save, new etc
at one time you have focus in text box or grid is there any way to trapp the keys for whole form instead of writing code in keypress event of every control separately
plz help
faisal iqbal ch
Love The Process Not The Result, Faiz H Sail
|
|
|
|
|
i think you are looking for mnemonics for buttons on your form as you want that when user is typing in some textbox and press a key and automatically a button pressed for this purpose you should change the caption of button in following way
&Save for save button now from anywhere on a form if user press Alt + S the button Save is pressed and code for its click event is invoked
Salman Sheikh
|
|
|
|
|
Which method is better for data binding (Design Time or Run Time).I have more than 1,00,000 records in the table which I want to show on the form.I this better to bind signle record at a time at run time or load the full table at once at design time.I knowat design time it will slow down the application as it will load the full table.
If I try at run time then how I can move to the next or previous record?
Any idea or sample code will be greatly appriciated.
Thanks In advance.
Ejaz
|
|
|
|
|
ejaz_pk wrote: Which method is better for data binding (Design Time or Run Time).
Neither. Which one you use depends on your requirements.
ejaz_pk wrote: I have more than 1,00,000 records in the table which I want to show on the form.
No, you don't. You have 1,000,000 records in a database, from which you retrieve an appropriate number of for display. Trying to show 1,000,000 records will do nothing but needly slow down the users experience. Holding that many records would also consume a enormous amount of memory.
The only time you'd ever retrieve that many records is if you're doing processing on each and every one of them. You never just retrieve that many "just because I might need them".
It will take a considerable amount of time to retrieve those records if the database is on the same machine as your application, and will take much, much longer if you have to get them over a network.
If you wanted to show that many records, depending on the control used, you would either use a Virtual mode of the control, like in a DataGridView, or implement some kind of paging operation.
ejaz_pk wrote: If I try at run time then how I can move to the next or previous record?
That's what the BindingNavigator class is for.
|
|
|
|
|
Sorry about the misunderstanding.I don't want to show all the records at once.What I mean is that user can see one record at a time but he can navigate to next and previous record as well.Is there is any way to do this.
Thanks for ur reply.
Ejaz
|
|
|
|
|
Hi,
I have uploaded a small sample for you at following location:
http://www.speedyshare.com/601871191.html[^]
Please download it and see if this helps.
I have used VB.Net 2005 and MS-ACCESS.
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Thanks John. I will try this.
Ejaz
|
|
|
|
|
Hi all,
How would one go about finding the latest file through vb??? I have file like this... "c:\TESTER\FORMAD.R02001" and "c:\TESTER\FORMAD.R02002" and "c:\TESTER\FORMAD.R02003" and so on...
the "c:\TESTER\FORMAD.R" section stays the same... so the "02001" and "02002" and "02003" and so on is the part that indicates the newes file where the highest number is the newest... how do i find this newest file through VB....
Thank you in advance
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Hello,
You can try this code. However, this is specific to the type of file name you have mentioned. To
test this code, put up a ListBox and a button control on the form. On button click event, paste
the following code.
Dim ofd As New FolderBrowserDialog
Dim result As DialogResult
result = ofd.ShowDialog()
If result = Windows.Forms.DialogResult.OK Then
Dim di As New IO.DirectoryInfo(ofd.SelectedPath)
Dim diar1 As IO.FileInfo() = di.GetFiles()
Dim dra As IO.FileInfo
ListBox1.Items.Clear()
For Each dra In diar1
ListBox1.Items.Add(dra)
Next
End If
Dim filearray() As String
Dim greater As Integer = 0
Dim index As Integer
Dim i As Integer
If ListBox1.Items.Count > 0 Then
ReDim filearray(ListBox1.Items.Count - 1)
End If
For i = 0 To ListBox1.Items.Count - 1
Dim s As String = ListBox1.Items(i).ToString
Dim substr As String = s.Substring(s.LastIndexOf(".") + 1)
If substr.StartsWith("R0") Then
filearray(i) = substr.Substring(2)
End If
Next
For i = 0 To filearray.Length - 1
If IsNumeric(filearray(i)) Then
If filearray(i) > greater Then
greater = filearray(i)
index = i
End If
End If
Next
If greater = 0 Then
MsgBox("No File Found")
Else
MsgBox(ListBox1.Items(i - 1).ToString & " is the latest file")
End If
I hope this helps.
Regards,
Allen Smith
Software Engineer
ComponentOne LLC
www.componentone.com
|
|
|
|
|
Thank you... WOW....
I will really give it a try and make changes if needed. Thank you for your time... it is much appreciated.
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Hi Support123,
If file is created sequentially,i.e. 02002 is created before 02003, then you can know newly created file by the CreationTime or CreationTimeUtc property of the FileInfo object. If you intend to know last updates file, you can use LastWriteTime or LastWriteTimeUtc properties of FileInfo object. Sort the file based on one of these properties in Descending order, top 1 file in the array (with index 0) will be the latest file.
I hope it'll give you the idea.
Regards
Aftab Sindhi
.NET Application Developer
|
|
|
|
|
I am trying to Import Address book (Name, MobileNo) from Excel file. Everything is working. Because of the importing speed issue, I decided to add the column ID (GUID) to DataTable. Running the sql statement SELECT NewID() AS ID, Name, MobileNo FROM tablename (tablename is worksheet name in Excel) raises an exception and its clear for me that NEWID() function is not working for OleDb(Excel) database, while same query runs fine in Sql Server. While trying to find some solutions, i figured that DataTable events (TableNewRow,RowChanging) can be used to assign new guid value to every row. But it still did not solve the problem because these events are not fired by OleDbDataAdapter.Fill() method. These events are fired if we use DataTable.Rows.Add() method.
Is there anybody have the solution to this problem? I don't want to loop through each row to add the value because records can be between 20,000 to more than 100,000. I expect quick response.
Aftab Sindhi
.NET Application Developer
|
|
|
|
|
AOA
I dont think Adding Column Id will speed up, instead check ur connectivity method or use DSN etc to speed up or simply import ur data to backend database by external means for once and all
thnx
Faisal iqbal Ch
|
|
|
|
|
Excel isn't exactly a database. The Jet database doesn't have a NewId() function like SQL Server T-SQL does.
You'll have to generate GUID's using your own code and populate that column yourself. You'll also have to verify that the GUID your code generates does not already exist anywhere in your data too.
Aftab Sindhi wrote: I don't want to loop through each row to add the value because records can be between 20,000 to more than 100,000.
Where you put the code is dictated by your process. If you already have a large table, but are just missing the GUIDs, you'll have to go through and add the values yourself, enumerating the entire table.
Aftab Sindhi wrote: I expect quick response.
You can "expect" all you want. We all do this on a volunteer basis and do not get paid at all. We'll get to answering your question in our own time, whenever we can.
|
|
|
|
|
Thanks Dave Kreskowiak and fazeepk for your quick response.
I am adding ID (GUID) column for internal purpose, which is must for my program. I am adding through the loop, which i wanted to eliminate, thats why i asked if there is auto generating way available. Thats what I mean to speed up.
Dear Dave Kreskowiak, I know Excel is not database and has no NEWID() function. Purpose to ask the question was, may be I've not enough knowledge about Excel. May be there is any other function/way available. But from your reply I can guess that I've no any option other than LOOP.
I think DataTable is not related to any database. Its pure .NET object. Why its not firing events, when it is populated by any means(i.e. FILLed by DataAdapter).
Well, thanks again to both of you. I'll just wait little, if there will be any other reply with solution.
Regards
Aftab Sindhi
.NET Application Developer
|
|
|
|
|
Aftab Sindhi wrote: I know Excel is not database and has no NEWID() function. Purpose to ask the question was, may be I've not enough knowledge about Excel.
It has nothing to do with Excel. There is no function in the Jet database engine that generates Guids. Jet is where the SQL expression is going to be parsed and executed. Excel is just used as datastore.
Aftab Sindhi wrote: May be there is any other function/way available
I already said the only way you've got is the one you're already using.
Aftab Sindhi wrote: I think DataTable is not related to any database.
No, it's not. It's an in-memory copy of the data and metadata retrieved from a database, or some other datastore.
Aftab Sindhi wrote: Why its not firing events, when it is populated by any means(i.e. FILLed by DataAdapter).
Probably because the events have to be wired up manually. You create a new instance of a DataTable, then you use AddHandler to wire up the events.
Also, when filling a DataTable with a DataAdapter, the events will not fire because the rows are not being added to the DataTable using the methods exposed by the DT. If they did, there would be a massive number of events firing, nearly all at once, while the table was being filled.
|
|
|
|
|
I have report with a list,,, in List I drag data from datasource,,, but I'am false drag data,,
how delete data source name of order "datasetname in properties list"
please help me..
|
|
|
|
|
um...what?
|
|
|
|
|
Yeah, I can't understand your question either.
|
|
|
|
|
=D I have problem more important to me
how get data from diferent list? and diferent group..
please help me......
|
|
|
|
|
I'm trying to create an application that utilizes one button to record the start and end time. If the user clicks it once the app records the current time as the start of the function. If it is clicked again the end time of a function is recorded. The name on the button preferrably would change from start to end. I'm looking into trying this due to a limitation on the number of buttons allowed on a school project.
Thanks
|
|
|
|
|
DateTime.Now will give you the time right now. You can store this and subtract it from the current time the second time the button is pressed. The button has a Text property you can use to change what text is on it.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have an existed Excel file (My_Excel.xls) with pure data, when I try to open it as database ... following SQL define requires a table name (what_table?) in order to access it:
<br />
conn = "Provider= Microsoft.Jet.OLEDB.4.0; Data Source=" & Environment.CurrentDirectory & "\My_Excel.xls; Extended Properties=Excel 8.0;"<br />
<br />
Dim SQLString As String = "SELECT * FROM what_table"<br />
<br />
DBCon = New OleDbConnection(conn)<br />
DBDat = New OleDbDataAdapter(SQLString, DBCon)<br />
DBCom = New OleDbCommandBuilder(DBDat)<br />
DatT = New DataTable<br />
<br />
DBCon.Open()<br />
DBDat.Fill(DatT)<br />
DBCon.Close()<br />
How can I define My_Excel.xls the table "what_table" in order to use the above code?
Thanks to any help
|
|
|
|
|
Define a named range in your spreadsheet called what_table that represents the data area you want to access.
Paul Marfleet
|
|
|
|
|
It is working.
Thanks
|
|
|
|