|
Chris# wrote:
Can I set ReadOnly for a user control?
The framework won't do this, this is something that needs to be done on a case-by-case basis because ReadOnly doesn't make sense to everything (progress control for example).
Also you need to keep in mind that ReadOnly is only a UI state, code can still read/write to the controls, the controls just don't accept user input.
With those ideas in mind...
private bool isReadOnly = false;
public bool ReadOnly
{
get
{
return isReadOnly;
}
set
{
isReadOnly = value;
textBox1.ReadOnly = isReadOnly;
}
} Good Luck,
James
Simplicity Rules!
|
|
|
|
|
In the .net framework is there a function that would process any pending messages in the message queue for the current thread, so while reading folders from a hard drive I could still move the window around.
Thanks
|
|
|
|
|
|
Hi,
Sorry, I know it maybe a bit dumb to ask this question.
But if I wrote class library that inherit some MFC classes,
can I use them in my C# project?
Thank you in advance
|
|
|
|
|
If you used managed C++, then I believe so. Ask in the MC++ forum to be sure.
|
|
|
|
|
They can't live in the *same* project, but you can use them together if you write an MC++ class library which wraps the MFC classes, then you can use that from a C# app, rather easily I might add The hard/tedious part is going to be wrapping the MFC class.
James
Simplicity Rules!
|
|
|
|
|
|
They can leave in the same solution so you can P/Invoke the C# or the unmanged code from C#
Al
|
|
|
|
|
In my MFC application, I draw lines over graphics and text
controls.
void CAboutDlg::OnButton1( )
{
CClientDC dc( this );
dc.MoveTo( 0, 0 );
dc.LineTo( 200, 200 );
}
The black line will draw over anything on the form.
--------------------------------------------------------
Now, in C# I cannot figure out how to draw on 'top' of the
controls.
private void Button1_Click(object sender, System.EventArgs
e)
{
Graphics g = CreateGraphics( );
g.DrawLine( Pens.Black, 0, 0, 200, 200 );
}
When I want to draw this line, it draws on the background
and does not draw over the bitmaps or text.
So, how do I draw on top of all the objects in a form?!
Transparent controls are not an option in this case.
Thanks in advance!!
|
|
|
|
|
because you tell him to create a graphics for the Window Form you are using
ex : suppose the text you want to put on the form is a label called "lab"
- make this :
Graphics g = lab.CreateGraphics();
instead of CreateGraphics because if you only write CreateGraphics, it's the sams as this.CreateGraphics.
Do you understand ??
I hope I help you
Jonathan Pouliot
|
|
|
|
|
Yes, I definitely understand. Unfortunately, it's not that easy.
I am needing to draw from one control to another across the entire form. The code you showed me basically only lets me draw within one control.
The final application has two fingerprint images and lines connecting identifying features between the two.
|
|
|
|
|
hi
i have stored form names in an arraylist. i need to create an object of each form in the arraylist and display it....
but when i create an object say f1 of arraylist frmnum[0]....it gives an error...
i have no idea how to go about this.....do i need to use typecasting....if yes ....please tell me how
bye
|
|
|
|
|
Yes is the answer to your question, you will need to typecast whatever you are getting back out of the ArrayList to the value type you need. This code cycles through the ArrayList arrlstApts which holds an array of points. To assign the value into apt we must cast it as such (Point[])
for(int i = 0; i < arrlstApts.Count; i++)
{
Point[] apt = (Point[])arrlstApts[i]
}
Nick Parker
|
|
|
|
|
i tried to typecast to Form type like this:
for(int i = 0; i < frmnum.Count; i++)
{
Form[] apt = (Form[])frmnum[i];
}
but it is giving an exception error saying "System Invalid Cast Exception" occurred
Additional Information :Specified Cast is not valid.
please tell me how to do it!
|
|
|
|
|
Maybe it is silly question.Is it possible to bind the Text property of ListBox to the column of database? If I set the DataSource and DisplayMember it shows all of the column in listbox,but I want to show each field seprately and use BindingContext.Position++ to show records in listbox.Is that possible?
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Anyone have the code worked out to scan every file in every directory on a hard drive to locate a single file possibly using DirectoryInfo and FileInfo?
Kyle
|
|
|
|
|
You could do something like this, inside the loop I am adding the file to a listbox:
string m_CurrentDirectory = "C:\";
string[] AllFiles = Directory.GetFiles(m_CurrentDirectory, "*.*");
foreach (string aFile in AllFiles)
{
string aFileName = GetFileNameFromPath(aFile);
this.listBox1.Items.Add(aFileName);
}
Nick Parker
|
|
|
|
|
Thanks Nick. This works well for a single directory but I need to develop a routine that will search not only the root of drive C but also every sub-directory until the entire harddrive has been searched.
Kyle
|
|
|
|
|
public void SearchHardDrive(string harddrive)
{
DirectoryInfo di = new DirectoryInfo(harddrive);
SearchDirectory(di);
}
private void SearchDirectory(DirectoryInfo di)
{
DirectoryInfo [] dirs = di.GetDirectories();
foreach(DirectoryInfo dir in dirs)
{
SearchDirectory(dir);
}
FileInfo [] files = di.GetFiles();
foreach(FileInfo file in files)
{
DoSomethingWithFileInfo(file);
}
}
private void DoSomethingWithFileInfo(FileInfo file)
{
} Enjoy
[Edit: Okay, I'm an idiot I click on the wrong post to reply too ]
James
Simplicity Rules!
|
|
|
|
|
James T. Johnson wrote:
[Edit: Okay, I'm an idiot I click on the wrong post to reply too ]
No way James, I didn't have time to reply to Kyles response yet. Thanks
Nick Parker
|
|
|
|
|
Thanks guys,
Here is an approach that works well.
Kyle
using System.Management;
string drive = "\"c:\"";
string filename = "\"test\"" ;
string extension = "\"exe\"";
string qry = String.Format( "select * from cim_logicalfile where drive={0} and filename={1} and extension={2}", drive, filename, extension);
ManagementObjectSearcher query = new ManagementObjectSearcher(qry); ManagementObjectCollection queryCollection = query.Get();
foreach(ManagementObject mo in queryCollection)
{
Console.WriteLine( "Name '{0}' :Path: '{1}' ",mo["Name"], mo["Path"]);
}
[Edit: The : P shows up as a smily face. Although I am happy with this result the smily face was unintentional. ]
|
|
|
|
|
I am trying to recreate the sidebar used in Explorer in Win XP in one of my programs. You know, the cute blue (or silver or green) thing with all the pretty icons and animations? Okay, I know, the first thing you did was probably turn that thing off. But I really want to have that look in a few of my C# forms.
I've had marginal success recreating the look using my own controls that call the UxTheme library. This is messier than I'd like, however, and doesn't include all the neat animation and other features that Explorer has.
This being Microsoft, I'm sure they abstracted that side bar into an object, possibly even a control of some sort. Does anyone know if this is accessable? Has anyone found any sort of documentation on the subject, even a little snippet? (I built my version of the sidebar using barely a few lines of information on UxTheme.dll, so I'm used to having a lack of documentation for these new XP display styles.)
Or has someone on Code Project already addressed this, and I missed it?
Thanks.
---------------
Jeremy Fuller
|
|
|
|
|
Does anyone know if you can make winforms skinnable? If so are there samples that I can look at? I have a control that I bought from softshape.com that allowed me to write skinnable software in vb 6 and I'm looking for the same tool or method within .NET to do the same thing.
|
|
|
|
|
Hi. there
Well, Now I'm make some kind of HTML editor with C#.
I'm try to drag-drop some HTML tag in DHTMLEdit control.
But I can't...
How can I drag-drop "HTML tag" in DHTMLEdit...
I wrote source like this...
that is what I want drag(HTML tag) in DHTMLEdit contol.
---------------------------------------------------------------------------
private void schemaTreeView_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e)
{
string s = e.Item.ToString();
switch (s){
case "TreeNode: VATDOC" :
s = "<input type='checkbox' checked value='ON'> </input>";
break;
default:
break;
}
DoDragDrop(s , DragDropEffects.All);
}
---------------------------------------------------------------------------
and you know, Drop in DHTMLEdit control, It will be work automatically so...
When I try to drop "<input type='checkbox' checked value='ON'> </input>", but it will be work like this "& lt;input...... & gt;......"
I think, DHTMLEditor has some kind of parser that work change "<" to "& lt;"...
somebody know How can I drag-drop HTML tag in DHTMLEdit control?
PS) sorry for my poor english.. ^^;;;
=^.^=
|
|
|
|
|
We have our own abstract class, inherited from Windows.Forms.control,and has some base methods we will use in it. Now we create our user control, which inherited from this abstract class, then we found our new user control can not use some features from Windows form designer, does anyone have the same situation, and how to deal with this?
Thanks.
|
|
|
|