|
Hello
Beside what Mikone has already said, I suggest the following if you want to implement file browsing in your Application:
1- You might want to take a look at FolderBrowseDialog class.
2- Populate a TreeView or a ListView with folders using methods provided in Directory class
3- If you want to implement Windows Explorer itself in your application, you can make a WebBrowser control, and set the URL to @"file:\\\C:\" to browse C: drive.
Regards
|
|
|
|
|
Hi All,
I am trying to develop a custom bitmap button, such that i want to make a part of the bitmap as transparent and the remaining part(Which is Non transparent) i want to set it as a button region.
Can anyone suggest me the approach to do that??
This is my first request..Hope i get a reply from someone.
Naveen
|
|
|
|
|
it will be done using gdi+
you can search for code in the above search box
|
|
|
|
|
Hi,
I am not sure whether I understood you correctly or not. You want to make a button which consists of a bitmap which has a transparent and (surprise surprise) a non-transparent area. Now you want that button to ignore the clicks which happen in the transparent area?
If so, you will have a lot of work. Afaik there is no built-in function to support such a feature. You probably have to start writing an own button-class, which inherits from system.windows.forms.control and make it act like you want it to...
So one possibility would be:
- Creating a new button class which inherits from control
- Creating handlers for the controls click events (they have to "judge" whether the click was on a non-transparent or transparent area)
- Using that Control in your projects.
That will be very difficulty but maybe there is an easier solution so just wait for a few more comments :P
Good luck,
mik
*edit* If you just want to make the button clickable (also will raise click event when the transparent area was clicked) you could take the "normal" button control and put the picture on it (picture property) - you could then turn off borders and stuff (just play around a bit with the properties). Doing so would result in the required button BUT it would also raise the click event if you click on the transparent area...
|
|
|
|
|
Hello
What Mikone said is right. You have to make your own class and inherit it from Button class. I only wanted to remind you that if you want to make your BackColor as transparent, don't forget:
1- In your class to call SetStyle(ControlStyles.SupportsTransparentBackColor) protected method to allow transparent BackColor.
2- Then make a new public event Call it for example SelectiveClick .
3- Make the original Click event as protected, handle it and then check for mouse position in the client area if it is within the transparent area or not. This is a very tricky part!! be careful that your image is not constant, you'd have to retreive the pixel at which the click was fired, and check if it has RGB value or not.
good Luck
PS.
If you want to make things easy for yourself, I suggest searching the articles for a button that already implements transparency.
Regards
|
|
|
|
|
Dear friends,
I want to traverse the metadata information of a database. For example, i've a database and i want to list all the user tables in that databse. Also, for each table, i want to list all the columns of the table. Similarly, for each column, i want to determine whether it is a primary key or a foreign key. I also want to determine constraints information.
What is the best method to do so in .NET ?
Imtiaz
|
|
|
|
|
See this[^] article.
/ravi
|
|
|
|
|
The time that I write code is not long, so I always confuse about what format should be the best for a procedure. In a case, if you write the code with the general thinking, maybe in the procedure it will have some repetitious use of some judge conditions or the calling of a sub_function. If you do this procedure with a unusual thinking, maybe the procedure can avoid the repetitions use. But ,it will make other people who read your code not quitely easy to understand. In this case, What way to write the code is the best one?
Following is my code of Drag&Drop for two listBox. The fucntion is :when two listbox in a form, user can drag left listbox item to right listbox which adds the item; and the right listbox items can Drag&Drop up and down.
General thinking is: First- DO left listbox's Drag&Drop action; Second- Do right listbox's Drag&Drop action. But this way should make the repetitious use of judge conditions or sub_fuction.With the way of my thinking, it can decrease the repetition.
//the Drag&Drop event
private void listBoxUCP_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(System.String)))
{
object item = e.Data.GetData(typeof(System.String));
// Perform drag-and-drop, depending upon the effect.
if (e.Effect == DragDropEffects.Move)
{
updateListBoxItems(source, listBoxUCP, item, e);
}
}
}
//sub_procedure
private void updateListBoxItems(ListBox sourceListBox, ListBox targetListBox, object sourceItem, DragEventArgs e)
{
int targetIndex = getTartgetIndexFromPoint(targetListBox, e);
int sourceIndex = targetListBox.SelectedIndex;
if (sourceListBox == targetListBox)
{
if (targetIndex == targetListBox.SelectedIndex)
return;
targetListBox.Items.RemoveAt(sourceIndex);
}
//if target listboxItem != null and insert place not in the end of the itemlist,
//use the insert method
if (targetIndex > 0 && targetIndex < targetListBox.Items.Count)
{
if (sourceListBox != targetListBox || sourceIndex > targetIndex)
targetIndex = targetIndex + 1;
targetListBox.Items.Insert(targetIndex, sourceItem);
targetListBox.SelectedIndex = targetIndex;
}
// else add the item in the end of the itemlist
else
{
targetListBox.Items.Add(sourceItem);
targetListBox.SelectedIndex = targetListBox.Items.Count - 1;
}
}
private int getTartgetIndexFromPoint(ListBox listBox, DragEventArgs e)
{
Point position = new Point(e.X, e.Y);
position = listBox.PointToClient(position);
return listBox.IndexFromPoint(position);
}
Can somebody tell me the defect of my code? You think what format is the best one of this function!
Thanks for any proposals!
|
|
|
|
|
Hello
I believe the major defect you need to format your code with is the pre tag, so that we could read it .. Please repost your code with the pre tags this time. You can add them by selecting your code, and pressing the pre button below the editting TextBox.
Regards
|
|
|
|
|
The modifyed code is following:
//the Drag&Drop event
private void listBoxUCP_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(System.String)))
{
object item = e.Data.GetData(typeof(System.String));
// Perform drag-and-drop, depending upon the effect.
if (e.Effect == DragDropEffects.Move)
{
updateListBoxItems(source, listBoxUCP, item, e);
}
}
}
    
//sub_procedure
private void updateListBoxItems(ListBox sourceListBox, ListBox targetListBox, object sourceItem, DragEventArgs e)
{
int targetIndex = getTartgetIndexFromPoint(targetListBox, e);
int sourceIndex = targetListBox.SelectedIndex;
if (sourceListBox == targetListBox)
{
if (targetIndex == targetListBox.SelectedIndex)
return;
targetListBox.Items.RemoveAt(sourceIndex);
}
/*if Drag the left listboxItem to the right listBox and drop in blank place or insert place not in the end of the itemlist,use the insert method*/
if (targetIndex > 0 && targetIndex < targetListBox.Items.Count)
{
if (sourceListBox != targetListBox || sourceIndex > targetIndex)
targetIndex = targetIndex + 1;
targetListBox.Items.Insert(targetIndex, sourceItem);
targetListBox.SelectedIndex = targetIndex;
}
// else add the item in the end of the itemlist
else
{
targetListBox.Items.Add(sourceItem);
targetListBox.SelectedIndex = targetListBox.Items.Count - 1;
}
}
private int getTartgetIndexFromPoint(ListBox listBox, DragEventArgs e)
{
Point position = new Point(e.X, e.Y);
position = listBox.PointToClient(position);
return listBox.IndexFromPoint(position);
}
Sorry for my fault!
Thanks for any proposals!
|
|
|
|
|
Hi,
Using the version of CR that comes with VS2005 is it necessary to include in the distribution package any merge items or redistributable files.
If so - what files are required and how do I add them to the distribution?
Glen Harvy
|
|
|
|
|
It depends on if the client computers already have it, in my case they did not. Google for Crystal Reports redistributable, and you should get the crystal reports website. You will need to download the merge module for the VS2005 version of Crystal Reports. Note that the clients will have to have admin access to install the merge module.
Aaron
|
|
|
|
|
This is where I get confused.
In the VS2005 documentation it talks about embedded reports BUT I guess this just refers to the actual report.cs file that I create and not to actually embedding the CR Engine into my project. Can you confirm this please.
Also, my program distribution (which will largely be via the net) has now blown out to over 26 meg in size by including the CR redistributable! Is it possible to distribute the redistributable as a seperate exercise?
Thanks for your advice,
Regards,
Glen Harvy
|
|
|
|
|
The CR Engine is a managed library that is referenced in your project. Most client computers that dont have the .NET SDK will lack these .dll's, which is why you need the merge module. 26mb sounds about right. You can create an installer just to install the merge module, then have your end users download it only if they experience problems.
To do that, just create a setup project, then in the solution panel right click and select add merge module. Browse to the CR_2005 merge module and select it. This will install the merge module only. Note, as I said before, your clients will need to have admin access to install.
If you need anything else, just let me know.
Aaron
|
|
|
|
|
I am reading this book, called MCAD/MCSD.NET Developing and Implementing Windows-Based Applications with Microsoft Visual
C# .NET and Microsoft Visual Studio .NET, the program ends on page 230. This code is from the book, and I have no clue what is going on. Do you have a clue to what might be the problem?
|
|
|
|
|
the problem is, that the compiler can not find the class rtbText inside the "known" namespaces. you will have to locate the line(s) where this error appears and modify them as required. Since i don't know the rtbText class i'm not able to tell you how to edit the code exactly. In general you should make yourself a bit more familiar to oop and .net
I've been googling for rtbText and found some examplecode which looks like rtbText were an object of RichTextBox class. If it is the same in your case, you probably are using rtbText as a type in a declaration or something similar.
Just review the code and maybe post the line where the error appears.
Good luck,
mik
|
|
|
|
|
Hello
1- Right Click on the field name that's causing the problem -you'd see a blue zigzag line beneath it- and see if there is a resolve MenuItem to the top of the ContextMenu that appears. If so, click on the solution in it. The problem was that you're missing a using directive.
2- If not check the references of your project and compare them to the ones in the book. You are missing a reference to a library.
Regards
|
|
|
|
|
Hi
Can anyone tell me how to embbeded C++ code in CSharp in application?
Can anyone help me in this matter.
Hoping for a favorable reply
From
Phijo Mathew Philip.
|
|
|
|
|
what do you mean?
if you want to use pointers in c# you must write the code in a unsafe block like this :
unsafe
{
int *i;
}
but in first you must set the option of your vs.net to use unsafe blocks in
Compiler Option .
i hope this be useful.
|
|
|
|
|
Hello
C++ is called unmanaged code, while C# is managed. They are two different languages despite the similarity in names. C++ compile to machine language while C# compile to IL language then to machine language at runtime. That's among other differences.
Whatever you want to do in C++ -excpet very few cases like inline assembly-, you still cane do with C#. For example:
1- You can make P/Invoke callse to old C++ libraries and Windows API functions
2- You can use pointers as Erfi showed you
3- You can include a C++ dll project in your solution and reference to it. Write your C++ code in that library.
4- you can reference to COM objects written in C++.
Regards
|
|
|
|
|
hi,
i want to send/receive some commands to one hardware device through GPIB card(one end is connected to System(USB port) one end is connected to device) in c#.net .
i wnat to know in which way i can communicate the device and what r requried fields to access the hardware through GPIB card.
plz send sample code for that .
it's very usefull to in my application.
Thanks
prem
Hi,
Thanks, if u think it's good.
otherwise sorry.
|
|
|
|
|
Hello
To access any port -Serial, LPT, USB, etc...- or device -eg. modem- in C3 you follow these steps:
1- Call Windows API CreateFile() function with the device name as the filename. ie. CreateFile("usb0001") for example.
2- Get The handle of the created file.
3- Supply that handle to the constructor of a FileStream object.
4- Use that FileStream object to read and write from/to the port/device.
And no, you can't construct a FileStream from the port directly. Sorry!
Regards
|
|
|
|
|
d
modified 22-Dec-14 16:57pm.
|
|
|
|
|
It is the class instance destructor
|
|
|
|
|
It's a destructor for the class. It will be called when the garbage collector is about to remove the object.
Generally you should only use a destructor in a class that implements IDisposable.
---
b { font-weight: normal; }
|
|
|
|