|
For your information it was actually ment to be two different questions!!! one for asp and the other for plain C#
I've got separate questions for separate programs and they just happen to have the same question related to them. I asked in separate places since i knew the asp question would be properly ansered in the asp board and then the C# question would be better asked in the C# board.
So maybe you should be less trigger happy when jumping folks!!!
oh, and if you didn't notice i didn't post the same exact question in both places, i made them each slightly different
but thank you for your concern for those maintaining the disk space on the servers, I'm sure they apreciate you watching their backs. they probably sleep better knowing Guffa has their backs.
but thats ok, heres a for your hard work!
you're worse than the soup nazi!
|
|
|
|
|
Well, the title differs, and the short information "using C#" in the ASP.NET question. Other than the questions are exactly identical, including spelling errors... If you intended to post two different questions, you should have posted two different questions. Then you wouldn't have people like me jumping you.
(The "using C#" information was totally superflous, by the way. As this is a strictly browser related questiuon, it is totally irrelevant what server language you use.)
How dare you compare me to the soup nazi? That wimp!
---
b { font-weight: normal; }
|
|
|
|
|
I neesd to get data from ana Access 2003 database and show them in in a datagrid in C#.Anybody can show me any tutorial about that?
|
|
|
|
|
http://www.codeproject.com/cs/database/csharpaccessdb.asp
Live Life King Size
Alomgir Miah
|
|
|
|
|
Can somebody help me find a regex that will locate this " | " in a string? The complete string is below... I'm new to regex but if I use an expression like "[ | ]" it finds all "|" plus all the " " (spaces) separately. Like I stated I want " | " together.
| Day | Amount | Direction | 3 | 100 | West | 5 | 43 | North | 5 | 44 | North West | 7 | 54 | South | 2 | 5995 | East | | | | | | | | | | 54 | 35345 | | | 543 | North | 6 | | West
If my explanation doesnt make sense, I want the above string to eventually look like with the use of replace...
Day,Amount,Direction,3,100,West,5,43,North,5,44,North West,7,54,South,2,5995,East,,,,,,,,,,54,35345,,,543,North,6,,West
And then based on a number n , replace every n th "," with a ";"
/\ |_ E X E GG
|
|
|
|
|
Fair warning, I'm not a regexp guru and while I have used them in textpad haven't used the c# regexp class, so I don't know the details of how it escapes things (tp supports 2 different rulesets so the standard isn't as tight as it could be). That said: IIRC | is a regexp control char that needs escaped, try escaping it with a \, also the [] construct's used to pick any of the chars inside of it not to define a substring. Try this instead: ( \| )
|
|
|
|
|
For your problem you it might be easier to use string.Split to get all values back and loop thru returned array to set values to either , or ;
string[] values = text.Split(new char[]{'|'});<br />
StringBuilder result = new StringBuilders();<br />
for (int i=0; i<values.Length; i++)<br />
{<br />
if (i > 0)<br />
{<br />
if (i == 3 || i == 5)<br />
sb.Append(';');<br />
else<br />
sb.Append(',');<br />
}<br />
<br />
sb.Append(values[i]);<br />
}<br />
<br />
return sb.ToString();
this will replace 3rd and 5th | with ; and all other with ,
|
|
|
|
|
Base
-------------------------
| public int iNo; |
| |
-------------------------
Class1 : Base Class2 : Base
---------------------------- --------------------------
| Class2 c2; | | private int iMyNo; |
| void Class1() | | public void SetMyNo()|
| { iNo = 10; | | { iMyNo = iNo; |
| c2 = new Class2(); | | } |
| c2.SetMyNo(); | --------------------------
| } |
----------------------------
This is my srtucture, I begin with Class1, which then init Base, and then sets iNo = 10. Next I create a new instance of Class2, which in turn again init Base. Now when I call c2.SetMyNo, it sets is to nothing, since there are two instances of Base. So how do I inherit Class2 from the same instance of Base, the super class of Class1?
There's someone in my head but it's not me - Pink Floyd
gunigugu
|
|
|
|
|
Your question is not very clear but if I understand it you have to two classes Class1 and Class2 both inheriting from Base.
Then you create two objects, c1 from Class1 and c2 from Class2. Both objects will have its own copy of the iNo, inhereted from Base. They are not the same iNo int variable just because they are defined in the same class, instead they refer to seperate variables in memory. You don't want to use inheritance in this case, you want to use aggregation
class Base
{
public int iNo;
}
class Class1
{
public Base myBase;
}
class Class2
{
public Base myBase;
}
class Test
{
[STAThread]
static void Main()
{
Base b = new Base();
b.iNo = 10;
Class1 c1 = new Class1();
c1.myBase = b;
Class2 c2 = new Class2();
c2.myBase = b;
Console.WriteLine("c1.myBase.iNo = " + c1.myBase.iNo);
Console.WriteLine("c2.myBase.iNo = " + c2.myBase.iNo);
c2.myBase.iNo = 5;
Console.WriteLine("c1.myBase.iNo = " + c1.myBase.iNo);
Console.WriteLine("c2.myBase.iNo = " + c2.myBase.iNo);
}
}
This will result in the following outpu
c1.myBase.iNo = 10
c2.myBase.iNo = 10
c1.myBase.iNo = 5
c2.myBase.iNo = 5
/Patric
My C# blog: C# Coach
|
|
|
|
|
Thank you very much, however I think I'm going to use static variables.
I'm quite new to programming and didn't know exactly how to work with static variables, so it didn't occurr to me.
Regards
There is someone in my head but it's not me - Pink Floyd
|
|
|
|
|
in this program there is a function to create a new desktop, and it includes the source, but it is in C++ and VB. is there a wway to create a new desktop in C#? If so, how? thanks
http://www.codeproject.com/win32/AntonioWinLock.asp
|
|
|
|
|
|
I have form1 and form2 (Modal form). when I click button on form1 it will show form2(Modal Form)then input name(TextBox), when finished, click ok button on form2, I want value in name(TextBox) back to form1. I don't know why it's alway null; thank you
|
|
|
|
|
This is a standard way to obtain information from dialogs (modal forms):
<br />
<br />
void ButtonClick(object oj, EventArgs ea) {<br />
<br />
val = "";<br />
<br />
if (form2.ShowDialog() == DialogResult.OK) {<br />
<br />
val = form2.Val;
}<br />
}<br />
<br />
Be careful to call Form.ShowDialog() ! If you call Form.Show(), it will be unmodal and your code passes before user types anything.
|
|
|
|
|
How do I instantiate a Color in C# using a red-green-blue value? In Java, I am used to:
Color c = new Color(255,128,0);
What is the equivalent in C#?
Thanks!
Mark
|
|
|
|
|
|
In other words,
Color c = Color.FromARGB(255, 255, 255);
|
|
|
|
|
Hi,
I'm trying to make a panel scrollable when it's smaller than a bitmap that's drawn on it, but the scrollbars don't show up... When I place a control, such as a button, out of the panel boundaries and set the AutoScroll property of the panel to true, I do see scroll bars, but not when the bitmap is larger than the panel. Hope I made it clear. Any ideas?
Yigal
|
|
|
|
|
whenever you want to update scrollbars, call:
myPanel.OnResize(EventArgs.Empty);
|
|
|
|
|
Thanks, but I don't think that would help. The panel simply ignores the bitmap when calculating the scroll margins.
Yigal
|
|
|
|
|
I have app working with MDIs - there are also panels with bitmaps and AutoScroll on, but it works fine.
My panel contains PictureBox and this PictureBox has fixed size (same as bitmap) and location (0, 0).
Maybe you just setting Panel.BackgroundImage property (??). This will not work. Panel 's scroll bars depends on size of controls it contains.
|
|
|
|
|
I've created some control that browses directories using TreeView on the left side and shows image thumbnails on the right side.
This control contains thumbnail management. It works this way:
Create hash string from image file address: C:\hello.png -> e8f838d8283kn4.jpg
Does e8f838d8283kn4.jpg exist?
Yes: load this file
No: 1) shrink source image and save as e8f838d8283kn4.jpg
2) dispose source image
But when I browse gallery of 100 3.0 mpx images, my app creates about half of them and then system tells me, there is not enough virtual memory. Next message comes from mscorlib.dll (Out of memory exception) and program falls down.
But thumbnails are small enough. If there are 100 128x128 thumbs, it takes up to:
128x128x3x100 = +- 4.6 MB
Every 3 mpx source image is disposed (using Image.Dispose() call) as well as thumbnails, when directory changes. So why is there lack of memory (my PC has about 240 MB RAM, this may not be a problem).
GC must clear all resources since system needs memory occupied by disposed images, doesn't?
|
|
|
|
|
I'd have to question how your making the thumbnail images and making absolutely sure of what your doing. It sounds like your not aactually creating the thumbnail, but making a copy of the original image and just showing it scaled down in a picturebox.
Without seeing the relevant code, it's impossible to tell you what's going on.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
No, I'm not so silly.
This is the pseudo-code (loading and saving thumb) of my Thumbnail class:
<br />
Image source = Image.FromFile(sourcePath);<br />
Image img = new Bitmap(128, 128);<br />
<br />
Graphics grfx = Graphics.FromImage(img);<br />
grfx.DrawImage(img, ...)<br />
<br />
grfx.Dispose();<br />
source.Dispose();<br />
<br />
this.image = img;<br />
The thumbnail creation process runs on background and Thumbnail instance draws its image in overriden OnPaint method (not in PictureBox).
|
|
|
|
|
oh, sorry - this is on the one line:
<br />
grfx.DrawImage(source, new Rectangle(..., 128, 128), new Rectangle(... source.Size), GraphicsUnit.Pixel);<br />
I draw the large image onto small image. Then I dispose Graphics object and source image.
Thumbnail control disposes the small 128x128 image in the Dispose() method.
|
|
|
|
|