|
Hi,
I'm trying to use the paint method to draw a table on a panel in a windows form. For some reason, the paint method is being called over and over again (I don't even know how many times!) when the form is opened. Does anybody know why this is happening? I'm fairly new to all this, so any insight is much appreciated.
Thanks!
RC
|
|
|
|
|
Common events like Paint and MouseMove fire very frequently. That's the nature of the beast.
Cheers,
josh
|
|
|
|
|
Please don't cross post.
---
b { font-weight: normal; }
|
|
|
|
|
Sorry!
I wasn't sure where to put that one...
RC
|
|
|
|
|
i've added a table into a datagridview, from sqlserver. the birthday column of the table needs the DateTime typed data, so when i write a String character in a cell of that column, an error occurs. by means of which event i can catch this error?
|
|
|
|
|
Hey Guys,
I have a c# application that uses win32 code to take a screencapture of a window running on the system. It then compares a portion of that screencapture with a bitmap that I have already pre-captured to see if that window is in a certain state.
When I first wrote the code it compared no problem, but now when I use it the two images are not EXACTLY the same. My application captured the right part of the graphic, but when I compared both images (by zooming in in photoshop) they are not the same. Looks like the screencapture was worse quality.
I saved the image I compare to as a Windows Bitmap 24 bit and the image I capture I am not sure what quality it is. Although my screen resolution is 32 bit.
Is there someway that I can make sure that the image I capture and the image I compare to are the same bit depth and quality using c#?
Here is some code I have
public static Bitmap GetWindowCaptureAsBitmap(int handle)<br />
{<br />
#region GetWindowCaptureAsBitmap<br />
IntPtr hWnd = new IntPtr(handle);<br />
Win32.Rect rc = new Win32.Rect();<br />
if (!Win32.GetWindowRect(hWnd, ref rc))<br />
return null;<br />
<br />
<br />
IntPtr hdcWindow = Win32.GetWindowDC(hWnd);<br />
<br />
Win32.BitBlt(hdcBitmap, 0, 0, rc.Width, rc.Height,<br />
hdcWindow, 0, 0, (int)Win32.TernaryRasterOperations.SRCCOPY);<br />
<br />
gfxBitmap.ReleaseHdc(hdcBitmap);<br />
<br />
<br />
Win32.ReleaseDC(hWnd, hdcWindow);<br />
<br />
gfxBitmap.Dispose();<br />
<br />
return bitmap;<br />
#endregion<br />
}<br />
private bool IsPlayersTurn(Image imgScreen)<br />
{<br />
#region IsPlayersTurn<br />
bool bRetVal = false;<br />
<br />
Image imgIsPlayerTurn = EmbeddedResources.LoadImage(EmbeddedResources.PartyIsPlayersTurn);<br />
Bitmap IsPlayerTurn = GetImage(imgScreen, 188, 463, 455, 11);<br />
Bitmap oCompare = new Bitmap(imgIsPlayerTurn);<br />
<br />
<br />
if (Imagio.ComparingImages.Compare(IsPlayerTurn, oCompare) == Imagio.ComparingImages.CompareResult.ciCompareOk)<br />
{<br />
bRetVal = true;<br />
Debug.WriteLine("Match OK");
}<br />
<br />
return bRetVal;<br />
#endregion<br />
}
Thanks,
Greg
-- modified at 10:20 Friday 16th June, 2006
|
|
|
|
|
I am trying to read text from a file, however, I keep getting "The process cannot access the file ... because it is being used by another process."
The issue is, I know that another process has the file open, but I need to be able to read the file without closing that process.
The weird thing is, I can open and edit the text file with notepad, but all the methods I have tried thus far in C# keep throwing the access error.
Here is one of the ways I am trying to open the file:
<br />
<br />
FileStream file;<br />
TextReader reader;<br />
<br />
try<br />
{<br />
file = new FileStream("C:\\file.log", FileMode.Open, FileAccess.Read, FileShare.Read);<br />
reader = new StreamReader(file);<br />
<br />
string test = reader.ReadLine();<br />
<br />
MessageBox.Show(test);<br />
}<br />
catch(Exception ex)<br />
{<br />
MessageBox.Show(ex.ToString());<br />
}<br />
<br />
-- modified at 11:55 Friday 16th June, 2006
|
|
|
|
|
after reading a line
put reader.Close();
and then try
|
|
|
|
|
It doesn't even make it that far. The error is thrown when I try opening the stream.
|
|
|
|
|
This code seems me ok, I think there could be some issues related to file/system security.
Riz
|
|
|
|
|
You're only reading one line, is this code in a loop? Can't help much without seeing the context in which that code executes.
Of course there is the possibility that another process is using the file. It's a log file, is there something that's logging to it?
Try something like...
try {
string text = string.Empty;
using (StreamReader reader = new StreamReader(@"C:\file.log")) {
text = reader.ReadToEnd();
reader.Close();
}
} catch {}
Visit BoneSoft.com
|
|
|
|
|
Hi,
I have some ini files with me. I want to create a wizard that would take this ini file as its input and output a C# class which when given to a control would give me means to edit the ini file. I'm speaking in the context of .Net. Ultimately i'm trying to create a tool that would make edition of the ini files possible. There is a wiward creation toll in .Net that is available. Please let me know of some good pointers to the same.
Thanks
Ashutosh
|
|
|
|
|
Hi. I'm writing Free Commander, and I have problem how to show files and folders in listView (like in Total Commander). My Second problem is that how to show local drives in combo box. I will be very greateful for any info.
|
|
|
|
|
|
I have number of textBox controls in my form.I want to save the text in the LostFocus or Leave Event.if i use mouse click to move one textbox to another, it work properly.but when i use "Tab Key" the value is different.
for example
i move TextBox1 to TextBox2 by mouse click, active control is TextBox1
i move TextBox1 to TextBox2 by "Tab Key", active control is TextBox2
but in both condition i need TextBox1.
How can i solve this problem.
|
|
|
|
|
use tabindex property
ex: TextBox1.TabIndex = 1;
TextBox2.TabIndex = 2;
aarthi
|
|
|
|
|
Dear All,
How to create selection formula for particular date using C#
Use the same formula in the C#
That is in the Crystal Report Viewer.
Please help me to give solution for this ASAP.
Have a great day.'
With Regards,
Siva
|
|
|
|
|
Exactly 9 out of 16 of the questions you have posted have had the word "Urgent" in the subject. Have you considered slowing down a little? Life should not be led at an "Urgent" state - its bad for your health!
Have a read of this[^] thread, which explains how to get better answers to your questions.
The current question you have posted is fragmented, and somewhat vague... What do you want to do with selecting dates? What do you mean by "Selection formula"? What formula are you using in crystal? Its easy enough to deplicate most date/time operations in C#.
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
Hi,
I have peculiar problem in reading an excel file to Dataset. That is, I have stored one excel file in my desktop. The same file is stored in my C drive also. While running the application, if the file is from desktop, it is throwing error that " Microsoft Jet Database Engine couldn't open the file....". But if the file is reads from C drive, it is reading correctly. Anybody has any solution for this? Why it is not reading the file from desktop? Following is the code I'm using for reading file:
private void btnReadFile_Click(object sender, System.EventArgs e)
{
string strFilePath;
strFilePath=File1.Value; // I'm using FileField HTML control.
GetDataFromXL(strFilePath);
}
private void GetDataFromXL(string fullfilepath)
{
try
{
string strConnectionString =string.Empty;
int NoofRecords;
strConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+fullfilepath+@";Extended Properties=""Excel 8.0;HDR=YES;""" ;
OleDbConnection cnCSV =new OleDbConnection (strConnectionString);
cnCSV.Open();
lblmessage.Text="File found and opened";
OleDbCommand cmdSelect = new OleDbCommand (@"SELECT * FROM [Sheet1$]", cnCSV);
OleDbDataAdapter daCSV = new OleDbDataAdapter();
daCSV.SelectCommand = cmdSelect;
DataTable dtCSV = new DataTable ();
daCSV.Fill(ds,"IndexesTbl");
NoofRecords=ds.Tables[0].Rows.Count;
}
catch(Exception ex)
{
errMessage=ex.Message;
lblmessage.Text=errMessage;
}
finally
{}
Anybody who knows, please help me. Advance thanks for the same.
Regards
Raja Raman S
Reuters India Pvt.Ltd.
Bangalore
|
|
|
|
|
Put this in your GetDataFromXL procedure, to see just what the Data Source parameter of the Connection String is being set to:
MessageBox.Show(fullfilepath,"Testing Path");
----------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Hi,
Thank you for the reply.
The fullfilepath string value is set as C:\Documents and Settings\raja.raman\Desktop\IndicesTbl.xls. The path is correct only. Still facing the error. Please help. Thanks a lot.
Regards,
Raja Raman S
Reuters India Pvt.Ltd.
Bangalore
|
|
|
|
|
Try this:
C:\\Documents and Settings\\raja.raman\\Desktop\\IndicesTbl.xls
----------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Hello!
I have a problem: I use a datagridview control to display data coming from a server application. The data is taken from a "generic" on the client side (that has in each element a cell from my table) and put in a dataset table (I've tried puttting it directly to the datagridview and I get the same problem). At runtime, everything works well, the datagridview gets populated with the correct data, the problem is when I try to scroll(v or h) the application freezes. The same if I use my keyboard and try to get to a non-visible cell. If I set No ScrollBars property, I can move with the keyboard around - no problem.
Any ideeas?
|
|
|
|
|
Well, it's not the number of rows that seems to be the problem, but the scrollbar - whenever a scrollbar has to be displayed the control freezes. I've also set scrollbars to "None" and everything works OK (except of course I have to use the keyboard to see everything), but this isn't the fix I need.
Anyway, below is the code I'm using... maybe is something wrong there ( my experience is quite limited):
DataTable temp=new DataTable();
DataRow newRow;
DataColumn newCol;
ds1.Tables.Clear();
ds1.Tables.Add(temp);
i = 0; j = 0; prima = true;
newRow = temp.NewRow(); newRow.BeginEdit();
for (i = 0; i < fp.lista_selectie.Count; i++) //fp is the parent form
{
if (fp.lista_selectie[i] != "##rr##") //##rr## is what I'm putting beetwen rows
if (prima) //used to add columns when adding the first row
{
newCol = new DataColumn(i.ToString());
temp.Columns.Add(newCol);
newRow[j++] = fp.lista_selectie[i].ToString();
}
else
newRow[j++] = fp.lista_selectie[i].ToString();
else
{
newRow.EndEdit();
temp.Rows.Add(newRow);
newRow = temp.NewRow();
newRow.BeginEdit();
j = 0; prima = false;
}
}
dGV1.DataSource = temp;
I'm using VS2005.
Any ideeas? Or going back to Listview?
-- modified at 7:21 Wednesday 21st June, 2006
|
|
|
|
|
Is there a possibility (net 2.0) to check if a class is inherited from another class? I have no instances of the 2 classes only types.
e.g.
class A:class B
{
}
class B:class C{
}
class a inherits from class B? -> yes....
Regards
Hansjörg
Edit/Delete Message
|
|
|
|