|
Hi,
Omkar Ghaisas wrote: My first task is to reorder the XML string as per the required tag order and then create a datatable so that we can bind it to a gridview to show data in following format
Do you want an algorithm to reoder the XML string also?
I've just posted a way to insert an array list into a dataset's table. So you can create an array list with the items you want and then insert the array list into a dataset (or datatable). I'll post the code again.
ArrayList lst = new ArrayList();
lst.Add(1);
lst.Add(2);
lst.Add(3);
lst.Add(4);
lst.Add(5);
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt.Columns.Add();
dt.Columns.Add();
dt.Columns.Add();
dt.Columns.Add();
dt.Columns.Add();
ds.Tables.Add(dt);
ds.Tables[0].Rows.Add(lst.ToArray());
string items = "";
for (int i = 0 ; i < ds.Tables[0].Columns.Count ; i++)
{
items += ds.Tables[0].Rows[0][i].ToString();
}
MessageBox.Show(items);
Do your best to be the best
|
|
|
|
|
how to convert Bitmap to Icon
Palestine
|
|
|
|
|
Hello
It depends. If you want to do that using an external editor, there are tons of free icon editors. My favourite is MicroAngelo. Just google for "Fre Icon Editor" and you should find satisfying results.
If you want to it in your code -would be strange though-, this may take some workaround.
Regards
|
|
|
|
|
Nader Elshehabi wrote: this may take some workaround.
It's actually pretty simple. See my reply below.
|
|
|
|
|
Bitmap myBitmap = ...;
IntPtr bitmapIconHandle = myBitmap.GetHIcon();
Icon myIcon = Icon.FromHandle(bitmapIconHandle);
|
|
|
|
|
Hello
Nice catch. Got my 5.
The workaround I was thinking of is the dimensions. You wouldn't know in what dimensions the bitmap would be. I didn't know that GetHicon() would take care of that too.
Regards
|
|
|
|
|
|
Judah Himango wrote: IntPtr bitmapIconHandle = myBitmap.GetHIcon();Icon myIcon = Icon.FromHandle(bitmapIconHandle);
I did that exactly in my program and when I tried to use the file created for a icon in (VS2008) it gave me an error that the file needs to be a picture that can be used as a icon
I also tryed making the icon file manualy.
MemoryStream IconPic = new MemoryStream();
IconPic.Write(Convert.ToInt16(0));
IconPic.Write(Convert.ToInt16(1));
IconPic.Write(Convert.ToInt16(1));
IconPic.Write(Convert.ToByte(0));
IconPic.Write(Convert.ToByte(0));
IconPic.Write(0);
IconPic.Write(0);
IconPic.Write(Convert.ToInt16(0));
IconPic.Write(Convert.ToInt16(0));
IconPic.Write(Convert.ToInt32(WorkingImageInPNG.Length));
IconPic.Write(Convert.ToInt32(20));
IconPic.Write(""Bitmap converted to PNG"")
see http://en.wikipedia.org/wiki/ICO_(icon_image_file_format)[^] for the instructions that I followed.
Please help.
|
|
|
|
|
I want to know how to import an Excel file using ODBC connection
|
|
|
|
|
I am trying to devise a system for centrally handling events generated by controls in my application and passing these events to other controls who may be interested in them.
For example say I have an application where a control can add an employee to the system. The control does the necessary and then raises an event which is then passed to two other controls who may have to process this event.
I would like to define the event in one place and for the controls who want notification of the event to simply register this fact and then receive the events.
This is what I have so far but perhaps there is a better way, or maybe there is a nice design pattern which someone can point me to.
I have a common class called EventHandlerCommon which defines the EventArgs for the event and defines a public delegate: public delegate void EmployeeAddedEventHandler(object sender, EmployeeAddedEventArgs e)
The class then has a static method:
public static void RegisterEmployeeAddedEventHandler(EmployeeAddedEventHandler sourceMethod)
which adds the the delegate to an array of methods to call.
This class also has another static method:
public static void ProcessEmployeeAddedEvent(object sender, EmployeeAddedEventArgs e)
which can be called when the event is raised and will pass it to all the delegates in the array.
My main application has two user controls. Each has a constructor which registers their interest in the employee added event by creating a delegate and passing it to the static class described above:
EmployeeAddedEventHandler del = new EmployeeAddedEventHandler(MyLocalEmployeeAddedEventHandler); <br />
MyEventHandler.RegisterEmployeeAddedEventHandler(del);
The first user control actually generates the event so has:
public event EmployeeAddedEventHandler EmployeeAdded;
and raises this event when a button is pressed.
The main form for the application has an event handler to handle this event:
this.userControl1.EmployeeAdded += new EventHandlerCommon.EmployeeAddedEventHandler(this.userControl1_EmployeeAdded);
This calls the static method to pass this event to all the controls interested:
private void userControl11_EmployeeAdded(object sender, EmployeeAddedEventArgs e) <br />
{ <br />
MyEventHandler.ProcessEmployeeAddedEvent(sender, e); <br />
}
This seems to work ok. Each of the user controls registers their interest in the event and is passed the event when it is raised. Perhaps this is not the best way though. My concern is the connection between the main form of the application and its link to userControl1. What if userControl1 was programatically created during run time, how would the main form know it could raise an the employee added event.
Any advice in this area would be gratefully appreciated.
|
|
|
|
|
For event/notification handling, there are .NET event model and Observer/Subject design pattern. How is yours different than these two?
Best,
Jun
|
|
|
|
|
I am effectively using the .NET event model. My question seems to be how to handle controls that are programatically created. Say the main hub of my application deals with the events that controls can generate and passes these to the other controls to process.
If the main hub programatically creates a user control, how does it know what events this can fire and hook up an event handler to these?
|
|
|
|
|
GazzaJ wrote: controls can generate and passes these to the other controls to process
Hope this link can help.
GazzaJ wrote: If the main hub programatically creates a user control, how does it know what events this can fire and hook up an event handler to these?
I believe that you need to raise and consume events in your custom control. This link might be able to help.
Best,
Jun
|
|
|
|
|
Take a look at the smart client software factory (Google it, the first search page should contain various resources regarding this).
No need to reinvent the wheel.
|
|
|
|
|
This looks good although I am still on .NET 1.1 at the moment.
|
|
|
|
|
I need to divide a very large image (say 5-7 mpx) into smaller pieces (24 bpp Image objects). Algorithm is not a problem, the speed of used GDI+ method is.
Using Graphics.DrawImage() is slow, even when no interpolation is done. The problem is not in the count of pieces, but in the size of huge source image. Doesn't matter how large the pieces are, because the long time is taken by the reading of pixels from source.
I've thought about using unsafe pixel access, but still hope there's some method for obtaining smaller image from larger one quickly.
|
|
|
|
|
Libor Tinka wrote: because the long time is taken by the reading of pixels from source
I wouldn't read pixels. Locate each small piece on the original image and draw it to a separate graphic buffer. Then, you may either save it to a file or render it to the screen.
Best,
Jun
|
|
|
|
|
The drawing to separate buffer (doesn't matter how small the buffer is) is slow when working with large images. Drawing small area of 10 by 10 pixels from position [x,y] using
graphics.DrawImage(srcImage, new Rectangle(0, 0, 10, 10), x, y, 10, 10)
looks fast - try it on 7 megapixel image, it won't be.
|
|
|
|
|
|
Is there any way to get error numbers for errors in the VS error list? I've thought of doing an add-in that sort of replaces the error list and looks up error numbers, but that seems a bit clumsy.
|
|
|
|
|
I don't know how to get them programmically (you might want to try to attach a StreamReader to the csc output).
But you can go to "View" -> "Output".
You will there get the raw output of csc
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Right click the error message and Show Error Help.
At the top of the help window you will see a message like:
Visual C# Reference: Errors and Warnings
Compiler Error CS1501
|
|
|
|
|
I am creating Custom Workflow Activities for our company. One of the main hurdles to this is in order to make the activities easy to use, I need to access to a database. This way, I can present the users with choices for correctly configuring the activities. I have not done a lot with creating UITypeEditors. VS will be initially be used for configuring the properties.
Does anybody have any recommendations/tips for how to go about doing this?
|
|
|
|
|
Hello all,
I'm working on a project written by someone else that links to an encryption library using interop. I'm getting about 50 warnings about types in that assembly that cannot be marshalled by the runtime marshaller and will be passed as a pointer, blah blah.
The fact is, the program is still running. I would like to ignore these specific warnings during the build so I can find any others that may pop up. Replacing the encryption component or changing its interaction with the program is not allowed at this time, so any help would be very useful.
Thanks,
Will
|
|
|
|
|
In the project properties under "Build" you can enter the numbers of warnings to suppress.
There's an edit box named "Suppress warnings:"
#pragma warning disable 1234 will also work
regards
modified 12-Sep-18 21:01pm.
|
|
|
|