|
Under the project's properties go to the Debug options, select "Start External Program" and put the path to your app in the text field.
|
|
|
|
|
I'm at a loss. Hoping someone can help.
I'm creating a custom control which inherits from Control (not sure if that's where I went wrong to start with) but here's the problem.
Based on a property which holds an array of strings, a certain number of panels are added to the control.
When the setter function of the string array property is called, the panels are added as follows:
this.Controls.Clear();
foreach (string s in myStrings)
{
Panel newPanel = new Panel();
newPanel.Name = ...;
newPanel.Location = ...;
newPanel.Size = ...;
newPanel.Paint += new System.Windows.Forms.PaintEventHandler(panelTab_Paint);
this.Controls.Add(newPanel);
}
And the paint function callback looks something like this:
private void panelTab_Paint(object sender, PaintEventArgs e)
{
}
So the problem is that, inside the function above, the value for e.ClipRectangle is {X = 0 Y = 0 Width = 0 Height = 0} which is obviously not right. The size of the Panel which can be obtained through sender is a valid size but why is the ClipRectangle of the PaintEventArgs value zero?
|
|
|
|
|
I'm not sure, but you could also check e.Graphics.Clip , e.Graphics.ClipBounds and e.Graphics.VisisbleClibBounds . You probably want to try ClipBounds though.
My current favourite word is: Nipple!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
The thing is, I'm not so much interested in obtaining those values, I mean I can quite easily do that by using (sender as Panel).Size and (sender as Panel).Location . I do want to be able to paint on the panel with e.Graphics.DrawLine(...) and such but as long as the e.ClipRectangle value is zero, nothing I draw on the panel will be successful as it falls outside of the clipping rectangle.
|
|
|
|
|
Oh bother! It seems my problem is bigger than just that. But at least, I suspect that if I can sort this one out it will be a sollution to the above as well.
I've now tried to implement an OnClick event for the Panels by adding this:
newPanel.Click += new EventHandler(panelTab_Click);
just before this:
this.Controls.Add(newPanel);
and defining panelTab_Click as follows:
private void panelTab_Click(object sender, EventArgs e)
{
}
However, even though the tabs are being added to the control they wouldn't respond to mouse clicks and the function above is never called. I'm reasonably sure that I'm adding the event handler correctly so I think my problem is with the way I'm adding these panels to the control in the first place. Any ideas?
modified on Sunday, September 14, 2008 1:42 PM
|
|
|
|
|
hi every body
i want know how can i send data to database without repetition
example:
string s="jack";
string x ="Axe";
String v ="jack";
string z ="tom";
string a="Axe";
with normal way "jack"&"Axe" will send twice to the database
i want send it one time only
how can i do this ??
|
|
|
|
|
Please stop using the bold font for your postings, it's annoying.
You could put all your strings into a hashtable, this will ignore duplicates:
Dictionary<string, string> strings = new Dictionary<string, string>();
strings[s] = s;
strings[x] = x;
strings[v] = v;
strings[z] = z;
strings[a] = a;
Then when adding them to the database simply iterate over the Values collection.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
First don't use bold on your question.
Check if string exists in database,if that string exists then don't insert otherwise do insert.
if (select count('stringvalue') from tablename where stringvaluecolumn='stringvalue')=0<br />
begin<br />
insert into tablename values('stringvalue')<br />
end<br />
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
you may want to do that in sql, database stuff you do in database ok?
ask if value exists?
NO can add to table
YES can´t add already there
(don´t know your database here)
create a procedure my_insert_procedure
@whatever varchar(50)
as
begin
if not exists(select * from my_table where whatever = @whatever)
begin
insert into my_table values (@whatever)
select 'OK: value added'
end
else
begin
select 'ERROR: that value already exists'
end
end
go
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Hey guys.
How can we find windows Temp folder in c# ?
Like this :
C:\Documents and Settings\Mds\Local Settings\Temp
Thanks in advance.
|
|
|
|
|
System.IO.Path.GetTempPath() should about do it
--
Real programmers don't comment their code. It was hard to write, it should be hard to understand.
|
|
|
|
|
|
The previous answer is correct and is what I use but (for the sake of completeness) there's also
Environment.GetEnvironmentVariable("TEMP");
or
Environment.GetEnvironmentVariable("TMP");
<edit>Didn't see Giorgi's answer till after posting as it was on the next page!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
Thanks a lot DaveyM69.
But I want to know is this correct :
Environment.GetEnvironmentVariable("temp");
|
|
|
|
|
It works (tried on XP Pro SP3) so I guess the string parameter isn't case sensitive. They are saved however in upper case so it would be safer to pass it that way.
You can see all the variables by opening control panel and selecting System (or right click My Computer and chose properties). On the Advanced tab click the Environment Variables button.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
Thank you very much DaveyM69.
|
|
|
|
|
I'm creating a simple remoting application on images and this is how my program goes. There's a server and there's a client and there's this DLL file that they commonly use so that they can communicate to each other remotely... The server contains the images. So when the client is executed, it contacts the server to get a specific image. So the request is successfuly sent to the server. The server found the image so it made use of the "Image theImage = Image.getFromFile('etc. etc.')" function.. it was successful, (i'm assuming the image now is in the "theImage" variable)... so the next thing the server to do now is to send the image back to the client to be displayed on a picture box... then BAAMM!! then the error popped out on the client side that "Native Image Not Found". How do i resolve this?
|
|
|
|
|
You'll want to be sending that image as a stream, then recreating a bitmap from that stream. It's quit simple really:
[server]
Bitmap img = new Bitmap(@"path");
Stream myStream = new MemoryStream();
img.Save(myStream, ImageFormat.Bmp);
...
[client]
Bitmap img = new Bitmap(myStream);
If this is what you'r already doing then err... I don't know. Sorry.
My current favourite word is: Nipple!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
yup.. i sent it as stream.. cause i thought you can just pass image objects that easy.. anyways thanks for the help
|
|
|
|
|
You can try out this.
In Server,
1. Read the image from the file.
2. Save the image onto a MemoryStream object.
3. Get the buffer from the MemoryStream using GetBuffer() method, this method will return the bytes from the memory stream.
Now you send this byte array to the client.
Now In Client,
1. Create new MemoryStream object and write the byte array received from server onto the MemoryStream.
2. Create new Image object from the MemoryStream using Image.FromStream() method and use this image object in the PictureBox.
Do more work
Make more mistakes
Learn more things
|
|
|
|
|
hi every body
i want know hot can i get the last word from string which inputed from user
example:
user entered:"my favorite song is ttt.mp3";
my question is how can i get "ttt.mp3" from the string
thanx every one
|
|
|
|
|
string txt = "some sample text";
string lastWord = txt.Substring(txt.LastIndexOf(" ")+1);
caveat: off the top of my head, not thoroughly unit-tested
|
|
|
|
|
ahmedhassan96 wrote: i want know hot can i get the last word from string which inputed from user
Two ways I can think of immediately:
String.Split()
or
String.LastIndexOf() and String.Substring()
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
split the string into an array using a space as the delimiter and get the last element in the array
or
identify the last space in the string and get the trailing characters
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
System.Text.RegularExpressions.Regex.Match(input, @"\S*$");
Edit: a better solution here[^].
Eslam Afifi
modified on Sunday, September 14, 2008 11:21 AM
|
|
|
|