|
Hi All,
i am using DataGridView which contains 4 Columns in my c# 2005 application .
When the user types some data in Column 1 and press enter the focus should go to Column 3 (or some other column) of the same row. in short how can i do programmatically set focus to specific cell(column) in a DataGridView.
how can i achive this i serached info but not able to find any relavent data .
|
|
|
|
|
Vijjuuuuuuuuu........... wrote: in short how can i do programmatically set focus to specific cell(column) in a DataGridView
By setting the CurrentCell[^] property
I are Troll
|
|
|
|
|
Hi Eddy,
Thanks for you reply .
sorry to ask you again not clear with the example given ,
my requirment is ,focus should move to paticular cell (i will specify the row and column number) when the user is inputing the data .
|
|
|
|
|
Vijjuuuuuuuuu........... wrote: my requirment is ,focus should move to paticular cell (i will specify the row and column number) when the user is inputing the data .
You can set the input-focus using the property "CurrentCell", like this;
dataGridView1.CurrentCell = dataGridView1[3, 4];
There's a "howto" article on this subject on MSDN[^]
I are Troll
|
|
|
|
|
Thank you very much for your prompt reply .
Now i am facing new problem, celling focusing is not correct.
its is focusing one row next to mentioned index .
for example i have 4 columns for my grid.
dataGridView1.CurrentCell = dataGridView1[0,2];
for the above code the focus to [1,2]
any idea ? if not pls igorne my quesiton.
|
|
|
|
|
Hi friends,
Can you'll help me to find another way for this..
i have two bitmaps, one is the mask bitmap which is a grey scale image and another is actual image, i am applying this mask on the image, i use getpixel & setpixel to apply the color of mask image as the alpha of the other image.. for small images it is fast but it becomes slow as the image size increases.. Is there any alternate way to do so?
Thanks in advance..
Regards
Samir
|
|
|
|
|
VCsamir wrote: i use getpixel & setpixel
These methods are really VERY slow.
VCsamir wrote: Is there any alternate way to do so?
Yes.
- One of the alternative methods is to lock the bits of your bitmap in memory and perform a direct access to the bitmap bits using unsafe block. There are plenty of examples and here[^] is a very brief one.
- Another option is to hide this pointer arithmetic in a class and provide some fast GetPixel and SetPixel implementations. You can find such a class in this[^] article (it is named UnsafeBitmap ).
- The third option is using ColorMatrix[^]. Here are some examples of its usage: 1[^], 2[^]. You can find more...
I'd also suggest you to have a look at this article and the other parts of the series: Image Processing for Dummies with C# and GDI+ Part 1 - Per Pixel Filters[^]
I hope this helps.
|
|
|
|
|
Thanks Sir for kind Help!!
Regards
Samir
|
|
|
|
|
You're welcome!
|
|
|
|
|
I have a problem when trying to compare two strings with different fonts.
the following comparison returns me a false result.
Assert.AreEqual("B", SomeFunction());
where
public string SomeFunction()
{
return value of a cell of Excel file using different Font;
}
in my case SomeFunction return a big big B.
Thanks for helping
|
|
|
|
|
|
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
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
|
|