|
Hi,
your code would translate to C# without a single pointer; almost all arguments to INPUT and OUTPUT
need the out keyowrd, no pointer stuff required. And the FILE stuff is handled
completely differently in .NET
May I suggest you look at some existing C# programs, and/or study a book on the language.
|
|
|
|
|
hi
i create a userControl that has a property named 'Caption' that works like TextBox.Text, in paint event, i wrote this code to display Caption property :
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawString(this.Caption, new Font("tahoma", 8), Brushes.Black, 0, 4);
}
it works good, but at designTime, when i add it to my form and set it's Caption, unlike textBox,it does not refresh automatic to display new Text, in paint event, also i use Invalidate(),Invalidate(false),Refresh() methods but it hasn't correct result.
how to solve my problem ?
thanks
|
|
|
|
|
Hi,
I would need to see more code to actually be able to help you out.
I must insist though that you shouldn't create (and not dispose of!) a new font for every paint action.
|
|
|
|
|
thanks for reply
no matter which font is used, the problem is that how to refresh my control to display new caption value after i set it in designTime.
here is my ful source Code :
public partial class UserControl1 : UserControl
{
private string _caption;
public string Caption
{
get { return _caption; }
set { _caption = value; }
}
public UserControl1()
{
InitializeComponent();
this.Height = 20;
this.Width = 100;
this.BackColor = Color.White;
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawString(this.Caption, new Font("tahoma", 8), Brushes.Black, 0, 4);
base.OnPaint(e);
}
}
thanks
|
|
|
|
|
Hi,
your Caption setter only modifies a string, it does not affect the GUI at all.
You need to include an Invalidate(); right there, and I would
swap the two lines in OnPaint to make sure the string is painted last.
|
|
|
|
|
thanks a lot Luc
i was modify Caption properties as follow :
public string Caption
{
get { return _caption; }
set
{
_caption = value;
this.Invalidate();
}
}
it was work good and my problem was solved.
thanks again.
regards
|
|
|
|
|
I'm trying to search the source code of the web page, but the string I declare doesn't hold enough characters. This is my code.
String webSource = String.Empty;
webSource = webBrowser1.DocumentText;
Form2 form2 = new Form2(webSource);
form2.Show();
When I check this in Internet Explorer, the source of my program is less than half of what it shows as in IE.
What's the problem and how can I fix it?
Thanks in advance.
|
|
|
|
|
I also want to add that I am trying to obtain the first image returned from a google image search. Right now, I am using the html of the search page to obtain the link to the first image. An alternative method would also be appreciated.
Thanks.
|
|
|
|
|
Im making a small app in which i can write telephone notes and other stuff at work. Im using a tab control to add different types of tabs and everything is working as intended. The thing is, id like to be able to save all the tabs and their contents when i close the app (or whenever i choose) so that i can i.e. restart the computer and such without loosing any notes. If anyone can point me in the right direction that would be great. Thanks!
I haven't lost 'till I'm the last one to cross the finishline.
|
|
|
|
|
You can either serialize the data or write it to file yourself using streams.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
ive been looking into serializing and it looks like i can do that. Besides, its as good an excuse as any to learn serializing The thing is, i dont have any concrete variables to serialize. Is there som way to "grab" all the controls and contents of the controls in the tab control or the entire form and then serialize that?
I haven't lost 'till I'm the last one to cross the finishline.
|
|
|
|
|
You can create custom class to store data from the tab control. Then just serialize it.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
I think I understand what your getting at, and then again not... I haven't coded for long and i don't realy know where to start with that so... Any helpful links tips or links? Anything would be nice.
I haven't lost 'till I'm the last one to cross the finishline.
|
|
|
|
|
|
Man that is one advanced program! For my standards atleast But it helped me alot actually. I think i get what you are doing when you save the file paths and serialize them to be used later. The thing is, i dont know how to do that with my tabs. When i choose to save the tabs i dont know how to get the tabs and the contents of the tabs. Is there some way to get all the tabs in the tab control, and the contents of the tabs (text in text boxes and such)?
I haven't lost 'till I'm the last one to cross the finishline.
|
|
|
|
|
TabPageCollection returns all the tabs in tab control. In order to get contents of the tab, you can build your own class to hold data and use databinding so that it will be automatically populated by the values of the controls on the tabpage.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
hi,
I want to write a program or a service which disconnect a dial up connection whenever for example the mouse doesn't move for 5 minutes or ...
please help me on this.
please tell in what library's i can find useful things.
thanks
|
|
|
|
|
|
I know that there is a possibility to get the name of the file after choosing it in the FileDialog, like this:
String str=fileDialog1.fileName()
The String(str) includes the full address of the file.
for example:
str="c:\windows\system\abc.txt"
but i want only the file name(abc.txt).
how can i receive only the file name and not the full address?
thank you
G.
|
|
|
|
|
use safefilename like this
DialogResult dr= openFileDialog1.ShowDialog();
if(dr==DialogResult.OK)
MessageBox.Show(openFileDialog1.SafeFileName);
|
|
|
|
|
Try Path.GetFileName[^] passing the full path you get from the file dialog. Also see other static methods in the Path[^] class in case you are interested.
|
|
|
|
|
hi,
you can also use 'FileInfo' class to get some information of your file in the given path.
|
|
|
|
|
If I have method with a non void return type is there a way to make the compiler check that the returned value has been explicitly assigned?
e.g.
When the method signature is
int DoSomething(int inValue);
Can the intended usage of
int retVal = DoSomething(iv);
in contrast to
DoSomething(iv);
actually be enforced.
I'd like a compiler warning for this situation but I haven't found one.
Alan.
|
|
|
|
|
Hi,
there is no such thing, a method will execute when called, whether the return value is
used somehow or not; so you can not enforce its use.
The situation is different with a property: you can not invoke a property unless
you either assign it a value (setter) or read AND use its value (getter).
|
|
|
|
|
Thanks for the response. You confirmed that the situation is as I had thought it to be, in that the use of the returned value is optional and cannot be checked.
Alan.
|
|
|
|