|
I think, if you add an item to listView, then you must also add a text to that item.
If you don't add a text to that item, then it will shows nothing.
ListViewItem item = new ListViewItem();
item.Text = "ABC";
listView.Items.Add(item);
|
|
|
|
|
hi....i m working in forms i want to show a form for 3 or 4 seconds and then start showing onther form for this i need to user a timer which display first form for 4 seconds then transfer control to other form....how can i user this timer???? i know sSystem.Timers.Timer is available but how to use it?????????????????
|
|
|
|
|
Your best bet, if you ever want to be a programmer in any shape or fashion, is to read the MSDN to find out how to use a timer. That's if you can't work it out, it's kind of self documenting. Then, if you can't work it out ( which would be odd, as it's very simple and the examples very clear ), post your code here so we can help you.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
i have used
System.Timers.Timer t=new System.Timers.Timer();
t.start();
t.end();
but now,,,,i dont know where to set the time interval 4 seconds in these 2 methods??????
|
|
|
|
|
This should help you
http://www.c-sharpcorner.com/UploadFile/mahesh/WorkingwithTimerControlinCSharp11302005054911AM/WorkingwithTimerControlinCSharp.aspx
http://www.csharphelp.com/archives/archive90.html
Coding C#
www.excitetemplate.com
|
|
|
|
|
|
Hi,
MahaKh wrote: .i m working in forms
if it is WinForms you are using, then System.Windows.Forms.Timer would be easier for your needs, as it ticks on the GUI thread.
For all timers: there is initialization including starting the timer, and there is event handling (a Tick event or Elapsed event depending on timer).
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Wow, it still amazes me that people have never heard of Google!
Is this really that hard to figure out?
Google: C# timer[^]
Using Google, you get quicker response, more examples, and plenty of choices. IMHO, many questions that get posted should be looked for on google first.
_____________
Joe
|
|
|
|
|
Opps, dup post.
|
|
|
|
|
public Hashtable FetchArray(ref OdbcDataReader reader)
{
int counter = 0;
int integer = reader.FieldCount;
Hashtable hashtable = new Hashtable();
if (reader.Read())
{
for (int i = 0; i <= integer+1; i++)
{
hashtable.Add(reader.GetName(i), reader.GetValue(i));
}
counter++;
}
return hashtable;
}
Im using MySQL Connector/ODBC 5.1
|
|
|
|
|
Haven't tried it, but...
Frozzeg wrote: int integer = reader.FieldCount;
...
for (int i = 0; i <= integer+1; i++)
Isn't that reading FieldCount + 1 entries?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
I don't think so. It attempts to read FieldCount+2 entries.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
My bad. Missed the "=" in "<=" - I blame Monday morning disease!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Frozzeg wrote: for (int i = 0; i <= integer+1; i++)
It should be
for (int i = 0; i<integer; i++)
DbDataReader columns store collection is ZERO based.
Life is a stage and we are all actors!
|
|
|
|
|
|
It has to, because that fixes your ( very obvious ) bug. How about you learn to use the debugger, then examine the code to work out exactly what is wrong ? You can then ask here and you'll get a real answer, because you will ask an intelligent question
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
In the first message, I pointed to a code string with an error
|
|
|
|
|
Yes that is true, you get expection when accsess an index that doesn't exsist.
If you have 3 indexes.
for (int i=0; i<=index+1;i++)
first part: i<=index. when you count 3, loop will do extra loop because of '<=' will do extra loop till i gets to 3. but it is zero based index and if i gets to 3, there are 4 indexes already, while reader have only 3. The second part is +1. Lose it. if you wan't to keep <= then use instead index+1 use index-1
edit: Also all exceptions comes with description, probably yours came with "Index out of boundary". When you wan't to know what is wrong,sometimes it is not enough the place and witch expection. All exceptions comes with a message
Frozzeg wrote: In the first message, I pointed to a code string with an error
You only pointed where AccessViolationException happens
edit 2: Copy paste from MSDN
Remarks
An access violation occurs in unmanaged or unsafe code when the code attempts to read or write to memory that has not been allocated, or to which it does not have access. This usually occurs because a pointer has a bad value. Not all reads or writes through bad pointers lead to access violations, so an access violation usually indicates that several reads or writes have occurred through bad pointers, and that memory might be corrupted. Thus, access violations almost always indicate serious programming errors. In the .NET Framework version 2.0, an AccessViolationException clearly identifies these serious errors.
In programs consisting entirely of verifiable managed code, all references are either valid or null, and access violations are impossible. An AccessViolationException occurs only when verifiable managed code interacts with unmanaged code or with unsafe managed code.
Version Information
This exception is new in the .NET Framework version 2.0. In earlier versions of the .NET Framework, an access violation in unmanaged code or unsafe managed code is represented by a NullReferenceException in managed code. A NullReferenceException is also thrown when a null reference is dereferenced in verifiable managed code, an occurrence that does not involve data corruption, and there is no way to distinguish between the two situations in versions 1.0 or 1.1.
modified on Monday, August 17, 2009 5:09 AM
|
|
|
|
|
Frozzeg wrote: for (int i = 0; i <= integer+1; i++)
How very odd. Why would you want to count to integer+1, that will be 2 more than the number of fields.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
It was a stupid mistake in "for", I mistakenly used instead of - +, thx but i still have AccessViolationException
P.S. sry for my English
|
|
|
|
|
And what kind of accsess vaiolation occorus: please post detail. Including its message
|
|
|
|
|
System.AccessViolationException was unhandled
Message="Attempting to read or write protected memory. This often indicates that other memory is damaged."
Source="System.Data"
StackTrace:
в System.Data.Common.UnsafeNativeMethods.SQLGetData(OdbcStatementHandle StatementHandle, UInt16 ColumnNumber, SQL_C TargetType, CNativeBuffer TargetValue, IntPtr BufferLength, IntPtr& StrLen_or_Ind)
в System.Data.Odbc.OdbcStatementHandle.GetData(Int32 index, SQL_C sqlctype, CNativeBuffer buffer, Int32 cb, IntPtr& cbActual)
в System.Data.Odbc.OdbcDataReader.GetData(Int32 i, SQL_C sqlctype, Int32 cb, Int32& cbActualOut)
в System.Data.Odbc.OdbcDataReader.internalGetString(Int32 i)
в System.Data.Odbc.OdbcDataReader.GetValue(Int32 i, TypeMap typemap)
в System.Data.Odbc.OdbcDataReader.GetValue(Int32 i)
в FMySQLClient.MySQL.FetchArray(OdbcDataReader& reader) в C:\FMySQLClient\FMySQLClient\MySQL.cs:line 199
в FMySQLClient.Form1.button1_Click(Object sender, EventArgs e) в C:\FMySQLClient\FMySQLClient\Form1.cs:line 30
в System.Windows.Forms.Control.OnClick(EventArgs e)
в System.Windows.Forms.Button.OnClick(EventArgs e)
в System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
в System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
в System.Windows.Forms.Control.WndProc(Message& m)
в System.Windows.Forms.ButtonBase.WndProc(Message& m)
в System.Windows.Forms.Button.WndProc(Message& m)
в System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
в System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
в System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
в System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
в System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
в System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
в System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
в System.Windows.Forms.Application.Run(Form mainForm)
в FMySQLClient.Program.Main() в C:\FMySQLClient\FMySQLClient\Program.cs:line 18
в System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
в System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
в Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
в System.Threading.ThreadHelper.ThreadStart_Context(Object state)
в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
в System.Threading.ThreadHelper.ThreadStart()
InnerException:
|
|
|
|
|
Does the loop run at least once?
I suspect it is connector problem. You coud try using MySql Connector/Net(I Used it, because other connectors were painfull to get them working). It is a form of external dll that you can reference to it. And you are not required to install it as it is required with ODBC connector.
Try asking in their forum, you coud stumble upon a bug.
|
|
|
|
|
"Does the loop run at least once?" - no
Ok, thx
|
|
|
|
|
I say that you are to use.
for (int i = 0; i <= integer-1; i++)
or
for (int i = 0; i < integer; i++)
If reader.FieldCount = 4 get the i parts 0,1,2,3
|
|
|
|
|