|
We're a bit impatient today, aren't we?
It usually takes a day or two to get a reply here, as most of our members have real jobs and can't spend all their time surfing the site for questions to answer. Be more patient, and you will be rewarded.
As a beginner myself, I'm not an authority to depend on, but the first thing I noticed about your post is that your code is using Assert to do a simple comparison. I did a bit of research and found that Assert is a method used in debugging, not application code. And specifically, the .IsEqual method is really thorough, and will fail if there is anything at all different between two arguments, including fonts.
I suspect that you are trying to compare the character values, and so I wonder why you don't first cast the imported value from Excel to a string type, then use a simple if (A == B) comparison. Post a bit more of your code, and maybe you will be rewarded with a better answer.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Thank you for replying.
In my code, i use Assert.AreEqual(strA,strB) to compare two string (this function is in NUnit Framework -test driven development).
Where strA is "B" and strB = a string value returned from my SomeFunction.
Again Thanks.
|
|
|
|
|
In code a character is a character; it has no font properties. Comparing "B" to "B" will always yield equal regardless of how those characters are displayed on screen or paper.
huonghue wrote: where
public string SomeFunction()
{
return value of a cell of Excel file using different Font;
}
in my case SomeFunction return a big big B.
This is not possible unless your function is returning a bitmap image of a large character.
MVP 2010 - are they mad?
|
|
|
|
|
Thanks for replying to my post.
One thing i didn't tell is that my excel file used Japanese font. When i open excel file i see B character, but for some reason it's not B but big B.
Thanks.
|
|
|
|
|
huonghue wrote: it's not B but big B.
???
MVP 2010 - are they mad?
|
|
|
|
|
I read that if I successfully insert one row of data or delete one row of data, the sql server will return me 1.
But when I try it, it returns me -1 instead of 1 although the row of data is successfully inserted or deleted.
Anyone here could enlighten me if I got something wrong? Thank you very much in advance.
SqlConnection con = new SqlConnection(GUIInitializer.DBconnectionString);
SqlCommand cmd = new SqlCommand(GUIInitializer.stp_GUI_DELETEITEMAIRLINEMAPPING, con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@ITEM_CODE", itemCode);
con.Open();
int rows = cmd.ExecuteNonQuery();
con.Close();
if (rows == -1)
{
DeleteItemData(itemCode);
}
else
MessageBox.Show("Item Code: " + itemCode + " Deletion FAILED!");
|
|
|
|
|
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1.
|
|
|
|
|
Thank you for the reply..
But the above code currently, returns me -1 even though only one row is affected. Is there anything wrong with the code?
Thanks again..
|
|
|
|
|
I think you should put "SET NOCOUNT ON" in Top of your SP and "SET NOCOUNT OFF" At the end of your SP
THANKS
|
|
|
|
|
Hi, Just tried it out. But still cannot. The insert is still replying me -1 when one row of data is added. But the delete is ok without adding NoCount.
Thank you for your help.
|
|
|
|
|
ok..got it..sorry for the trouble..
I didn't put the ( ) when I declare the variables in STP.
CREATE PROCEDURE [dbo].[stp_GUI_InsertAirlineData] (
@AIRLINE_CODE varchar(3),
@AIRLINE_DESC nvarchar(50) )
|
|
|
|
|
Cool!Enjoy!
|
|
|
|
|
Thanks anyway.. ..Cheers!
|
|
|
|
|
i did encounter the same problem as the guy have:
(from http://bytes.com/topic/c-sharp/answers/859828-c-transparent-control-problem)
Anybody can help?
thanks.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Hello there !
I'm developing a Windows appliciation that involves so called
"Transparent Controls". As you would probably know, the only ( as far
as i know ) way to achieve a fully transparent control in C# is to add
the so called "Transparent style" to your control
("WS_EX_TRANSPARENT"). There are numerous articles how to achieve this
and the method is ALMOST always one and the same:
1. protected override CreateParams CreateParams
2. {
3. get
4. {
5. CreateParams cp=base.CreateParams;
6. cp.ExStyle|=0x00000020; //WS_EX_TRANSPARENT
7. return cp;
8. }
9. }
10. protected override void OnPaintBackground(PaintEventArgs pevent)
11. {
12. //do not allow the background to be painted
13. }
14.
And that works fine! ( well .... at least all say that ..... and all
the articles say so ), but am i missing something or that method has
SOME SERIOUS problems that nobody can see ?
For example the Z-order. The following piece of code creates simply a
transparent control that draws a line across itself with a random
color:
1. using System;
2. using System.Collections.Generic;
3. using System.Text;
4. using System.Windows.Forms;
5. using System.Drawing;
6. namespace WindowsApplication16
7. {
8. public class HrisTranspControl : Control
9. {
10. private Pen _drawingPen;
11. public HrisTranspControl()
12. {
13. Random rnd = new Random();
14. this._drawingPen = new System.Drawing.Pen(new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(rnd.Next(0,255),rnd.Next(0,255), rnd.Next(0,255))),5);
15. }
16. protected override CreateParams CreateParams
17. {
18. get
19. {
20. CreateParams cp = base.CreateParams;
21. cp.ExStyle |= 0x00000020;
22. return cp;
23. }
24. }
25. protected override void OnPaintBackground(PaintEventArgs pevent)
26. {
27. // Do nothing
28. }
29. protected override void OnPaint(PaintEventArgs e)
30. {
31. base.OnPaint(e);
32. e.Graphics.DrawLine(_drawingPen, new System.Drawing.Point(0, 0), new System.Drawing.Point(this.Width, this.Height));
33. }
34. }
35. }
And so ... when u put few "line controls" on top of each other the
Z-ORDER goes to hell. You can't change it, its not corrent and it
changes randomly each time u select a random "line control".
I've tried A LOT of methods to fix that ( changing the z-order in
background, repainting the actual background because i think its
because the background is not drawn ... and so on ). None works. I'm
out of ideas and the worst part is i've almost finished the application
and right in the end i realize that bug and it kills me.
Please help !!!
The "line controls" were added in the order shows 1,2,3 , but the
Z-order appears to be different ( 1,3,2 ). In the current case "bring
to front" , "send to back" doesn't change the Z-ORDER
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
|
|
|
I want to add months and set the day as last day of that added month. I know i can do in the following way,
<br />
DateTime ldtManipulatedDate = new DateTime(1998,lintMonths,1).AddMonths(lintAddMonths);<br />
ldtManipulatedDate = new DateTime(ldtManipulatedDate.Year ,ldtManipulatedDate.Months,DateTime.DaysInMonth(<br />
ldtManipulatedDate.Year,ldtManipulatedDate.Months));<br />
The above code will first add months and then set the day as last day of that added month.
But i want this in one step as i am instantiating two times.
Please let me know how can i do it?
|
|
|
|
|
Hi,
from year and month:
DateTime dt=new DateTime(year, month, 1).AddMonths(monthsToAdd+1).AddDays(-1);
or from DateTime:
dt=dt.AddMonths(monthToAdd+1).AddDays(-dt.Day);
dt=dt.AddDays(1-dt.Day).AddMonths(monthToAdd+1).AddDays(-1);
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
modified on Wednesday, February 3, 2010 10:08 PM
|
|
|
|
|
Thanks Luc!!
Why didnt it strike in my mind...
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
fixed a bug
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
can anyone point me in the right direction on how to right click on a listbox entry and be able to rename it.
my project logs video clips in 60 sec files and stores them in a folder, i use filesystemwatcher to populate a listbox of with the file names as they are created
minute 1
minute 2
minute 3
and so on...
i want to be able to select a file and rename it so i can find that bit of video quicker
so far i got
private void listBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
//not sure what to add here
any help would be great
using visual studio 2008 c#
kenny
|
|
|
|
|
Hi,
1.
why use MouseDown? I would set SelectionMode.One, then use SelectedIndexChanged event and SelectedIndex property. Don't forget to check for >=0. Or better yet, use DoubleClick event, so user must double click to enter rename mode.
2.
how will you enter the new name? just typing at the ListBox? trough a TextBox?
and when do you want to rename? on hitting Enter? clicking a Button?
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
would like to enter new name by just typing at listbox, dont want to double click as i use that for playing the video file
kenny
|
|
|
|
|
I would go with Scott's suggestion (context menu), hence use the SelectedIndexChanged event, and the KeyPress event.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
I would use a context menu.
When the user right-clicks and selects rename you can pop up a dialog asking for the new value to be input into a textbox.
When the user clicks OK you can just update the selected item text to the text they entered.
|
|
|
|
|
Does anyone know any way to set a process to be the foreground window in managed code, I have a Process object and need to set that process to be the front form. I was previously using the user32.dll function SetForegroundWindow(p.MainWindowHandle); , but I know have a requirement to use only managed code. Any ideas?
|
|
|
|