|
Yes, well came to the conclusion that the error for me is that I thought it would be enough to add a line into the code and that would be that. But can see that I need to do more than that.
Basically tried to add
dt.Select("Status =1"); after reading the XML file and also tried to filter it like this
dataGridView1.DataSource = dtSelect("Status =1"); <- this actually gave an interesting output.
But seems that I wouldnt be able to get away with only a line of code thist time here.
So what would be the best way to do this? (just imagine that I have an XML file with more than 2000 Rows)
|
|
|
|
|
No guarantees that this will work but you could try adding a BindingSouce component to your form and then the bindings become
datagrid.DataSource = bindingSource1;
bindingsource1.DataSource = dt;
BindingSource has a Filter property that you can use.
In fact, if you search MSDN for BindingSource.Filter, the example uses XML which should make getting your stuff to work a bit easier.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Fantastic, worked first time - ehm after I remembered that there is a difference between 1 and '1'. But thanks for the headsup on BindingSource.
Cheers,
|
|
|
|
|
Hello sir
I need to convert excel file into image file using c#.then send me sample code for converting word file into image file. Please send me immediately.
Thanks and regards
Vivek
hi
|
|
|
|
|
Member 4388360 wrote: Please send me immediately.
Upon receipt of 500 pounds sterling I'll send you the code. Until then, go to rentacoder.com. This is not the place to demand code.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Member 4388360 wrote: Please send me immediately
You are joking right?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
Here's some sample pseudocode:
* Open xl file
* Show messagebox "URGENTZ! PLZ PRS PRNTSCRN! KTHXBYE!"
* Paste into bitmap
* save dat shizzle
|
|
|
|
|
Hi, im trying to Open multiple Ms Office files like Excel,PowerPoint & Word in my webBrowser, it works fine when im using Ms Office 2003 in other pc, but when i try to run the same application in another pc having Ms Office 2007 then instead of showing the MS Office file in webBrowser, it Opens the file in Ms Office. Does anyone know the solution to overcome this problem..
thanks in advance
|
|
|
|
|
muhammad_umair wrote: Does anyone know the solution to overcome this problem..
Probably yes, but I do not think that they will be writing any C# code to solve it.
Please follow the guidelines[^] and post your question to the correct forum.
|
|
|
|
|
Hello to all.
I'm new in this message board, and I couldn't find this subject elsewhere.
The thing is, I need to know if I can use the lock satement inside an overloaded method, i.e.:
public static string MyString = 0;
private static object objMyLock = new object();
public static void DoSomething(int Index, string Field)
{
lock (objMyLock)
{
MyString = Field + Index.ToString();
}
}
public static bool DoSomething(string Name, string Field)
{
lock (objMyLock)
{
MyString = Field + Name;
}
}
Does the lock Statement used like this, ensures that the variable MyString is changed by one thread at a time?
Thank you!
NMFPacheco - Portugal
|
|
|
|
|
"Does the lock Statement used like this, ensures that the variable MyString is changed by one thread at a time?"
Yes it should ensure.
But I wouldn't work with static objects / methods / etc..
|
|
|
|
|
Thanks for your reply.
"But I wouldn't work with static objects / methods / etc.."
For any special reason? Unsafe code/other, or simply not the best way?
|
|
|
|
|
At first I think, to implement a the basis of little modules/classes, is a better
way to solve problems.
Classes are in general more flexible through inheritance, access rights etc.
Example:
public class MultiThreadingClass
{
public MultiThreadingClass()
{
}
private object m_objSync = new object();
private int m_nValueA = 0;
private int m_szText = string.Empty;
public SyncObj
{
get
{
return m_objSync;
}
}
public Value
{
get
{
lock(objSync)
{
return m_nValue;
}
}
set
{
lock(objSync)
{
m_nValue = value;
}
}
}
public Text
{
get
{
lock(objSync)
{
return m_szText;
}
}
set
{
lock(objSync)
{
m_szText = value;
}
}
}
}
Thats not the best way to implement it, but out of this class you can be sure of the values (thread-safe). And if you need extern sync you just have to call lock([classInstance].SyncObj);
One more profit is, that you can have more than one instance of this class.
I hope I could explain you a little bit what I meant.
|
|
|
|
|
Thank you Covean,
I did understand and agree with you. But, in my specific case, I can not change the class where I am using the lock.
Besides that, the question is, if it is possible to use the same lock for covering all overloads of the same method.
Nuno
|
|
|
|
|
Yes if you use everywhere the same sync object.
In your case a static sync object maybe is also the better way.
|
|
|
|
|
i have a client application i which i need to connect to the remote machine on click of a button and localhost on every minute.is it possible. plz help me.
|
|
|
|
|
Can you be more specific as to how you want to connect to a machine ?
Is it a database connection you wish to establish ?
|
|
|
|
|
Bjorn Spruit wrote: Is it a database connection you wish to establish ?
No its not a database connection. it is a socket connection between the client and the server of the remote machine
|
|
|
|
|
Yes.. On every client request create a new thread and run the task in its own thread until it returns to its tread pool.
Just like what IIS does for every requests.
|
|
|
|
|
can u be more specific im not getting any idea about it.
you mean to say when client send or recieve a msg run a new thread and reconnect to the server
|
|
|
|
|
i have tried running threads in this format. but this also works only if button is clicked and only for 4 times but
i wish 1 client to connect to the server when button is clicked and other client will connect and close for each minute.
the code is:-
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < 4; i++)
{
Thread thread = new Thread(new ParameterizedThreadStart(round));
thread.Start();
thread.Join();
Thread.Sleep(100);
}
}
private void round(object val)
{
System.Net.IPAddress myIP;
System.Net.IPEndPoint myServer;
Socket socket;
string ip = (string)val;
try
{
myIP = System.Net.IPAddress.Parse(ip);
myServer = new System.Net.IPEndPoint(myIP, Int32.Parse("20000"));
socket=new Socket(AddressFamily.InterNetwork,SocketType.Stream ,ProtocolType.Tcp);
socket.Connect(myServer);
NetworkStream netStream=new NetworkStream(socket);
Byte[] byteMessage=new Byte[640];
string sendMessage="hello server";
byteMessage=System.Text.Encoding.Default.GetBytes( sendMessage.ToCharArray());
netStream.Write(byteMessage,0,byteMessage.Length);
netStream.Flush();
netStream.Close();
socket.Close();
}
catch (Exception ee)
{
MessageBox.Show(ee.Message);
}
}
|
|
|
|
|
I'm writing strings at a pre-determined location to a bitmap.
Though, it seems that if the location isn't "snapped to the grid", blurring occurs.
Simple example:
public Bitmap WriteToBitmap(Bitmap bitmapToWriteTo, float X_Pos, float Y_Pos)
{
Graphics g = Graphics.FromImage(bitmapToWriteTo);
g.SmoothingMode = SmoothingMode.AntiAlias;
g.TextRenderingHint = TextRenderingHint.AntiAlias;
g.InterpolationMode = InterpolationMode.HighQualityBilinear;
g.DrawString(this.text, this.font, new SolidBrush(Color.Black), X_Pos, Y_Pos, this.stringFormat);
return bitmapToWriteTo;
}
Nothing else is being done to the bitmap object or any of the other objects involved.
So you may consider the code above as being used as is.
The problem is, however, that using it like this, causes blurring in the text when drawn.
There is a solution to stop the blurring and that is by changing the TextRenderingHint:
g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
Now, this causes the text being drawn to be "snapped to a grid".
However, this messes up my positioning, making it look chaotic.
My question is this, how can I get the result of TextRenderingHint.AntiAliasGridFit, without losing the positioning.
And, to what "grid" is the text being snapped to and am I able to manipulate it ?
|
|
|
|
|
Here's the solution as I can tell it at this point.
Dropping the following code solved the bluring for me:
g.SmoothingMode = SmoothingMode.AntiAlias;
g.TextRenderingHint = TextRenderingHint.AntiAlias;
g.InterpolationMode = InterpolationMode.HighQualityBilinear;
From what I understood by reading Microsoft supplied information and the experiences from other developers, it's the Glyph hinting that causes the problem.
I increased the DPI of the originating Bitmap and dropped the hinting.
Problem solved.
Some positioning adjustments are required, but nothing I can't fix.
Hope this will help others as well.
|
|
|
|
|
Sorry, its not to the problem itself, but I'm wondering.
You say "it's the Glyph hinting that causes the problem".
But on MSDN it says that TextRenderingHintAntiAlias does no hinting.
From MSDN: "TextRenderingHintAntiAlias:
Specifies that a character is drawn using its antialiased glyph bitmap and no hinting. Stem width differences may be noticeable because hinting is turned off. "
|
|
|
|
|
True, that's what they say.
I suggest you try it out and see if there's Glyph manipulation.
Set the TextRenderingHint property of your Graphics object:
g.TextRenderingHint = TextRenderingHint.AntiAlias;
See how it's displayed.
Then remove it and compare the two.
Even though it's already visibly apparent, I would like to urge you to print the two results and compare them.
In my humble opinion, the AntiAlias touches the Glyph.
But I could be mistaken.
If I am mistaken and somehow I seem to have missed what the default does as opposed to what AntiAlias does, then please inform me.
Don't forget to add an informative link, not just for myself, but for others coming across this problem.
Thanks in advance.
Edit:
I indeed stand corrected.
Here's a link explaining how it works:
http://msdn.microsoft.com/en-us/library/ms534404%28VS.85%29.aspx
By setting the TextRenderingHint to AntiAlias, you kill the default corrective Glyph hinting the Graphics object does by itself.
Quote:
"TextRenderingHintSystemDefault
Specifies that a character is drawn using the currently selected system font smoothing mode (also called a rendering hint)."
Quote:
"TextRenderingHintAntiAlias
Specifies that a character is drawn using its antialiased glyph bitmap and no hinting. Stem width differences may be noticeable because hinting is turned off."
Thank you Covean for this insight
modified on Thursday, October 22, 2009 9:07 AM
|
|
|
|