|
Hello,
I wrote a method to convert image's color table.
public class convert
{
public static Bitmap bmp_convert(System.Drawing.Image pic)
{
Bitmap b = new Bitmap (pic);
BitmapData bmData =b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format16bppArgb1555);
b.UnlockBits(bmData);
return b;
}
}
unfortunately, I can't convert my image to Format8bppIndexed (or any indexed format) while to the other formats I can...(like: Format16bppArgb1555),why? and how can I fix it?
|
|
|
|
|
How would I go about embedding a combobox in a cell of a listview when set to details view? I've looked at this article ListViewEmbeddedControls[^] but unfortuatly the combobox height is bigger than the row height. Can I maybe overwrite the row height before drawing?
Thanks,
Rob Tomson
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
Hi:
I'm using a datagrid in my project to display data from a dataset. The dataset is bound to the datagrid and several textBoxes. //this.datagrid.DataSource = this.dataSet; this.tbFamily.DataBindings.Add("Text",this.dataSet,"Table.Family");
I assigned the bound dataset to a bindingManager because I need to show the currently selected data from the datagrid in textboxes. //BindingManagerBase manager = this.BindingContext[this.ds, "Table"];
I use //this.manager.Position = this.datagrid.CurrentRowIndex; within a CurrentCellChanged event to control the position of the manager each time the user selects a new row in the datagrid..
This works fine until the datagrid is sorted by clicking on the Columnheader because the "sorted" data doesn't seem to "remember" its index prior to sorting...thereby displaying the wrong data in the textboxes
Can someone please show some code that I can use to make sure that sorted data remembers the pre-sorted index?
Thank you.
|
|
|
|
|
If you add this code to your program, the datagrid will be in a sorted format
CurrencyManager cm = (CurrencyManager)this.BindingContext[this.dataSet, "Table.Family"];
DataView dv = (DataView)cm.List;
dv.Sort = "xxx"; // the column you want to sorted.
Then you can use
BindingManagerBase manager = this.BindingContext[this.dataSet, "Table.Family"];
DataRowView view = (DataRowView) manager.Current;
DataRow row = view.Row;
to get the row you want.
Don't try to use the index, because it's not accurate if you delete a record from the datagrid.
Hope this helps
Asura
|
|
|
|
|
Thanks Asura. It was helpful.
|
|
|
|
|
I have two controls each of which have loops (we will call loop 1 and loop 2) that call a central function that sends and gets data via serial (we will call Communication function). Only one loop is to run at a time. The problem I am having is when the user requests loop 2 while loop 1 just started. Loop 2 alerts loop 1 to stop, but if loop 1 just started, it will still be calling the communication function until it finishes.
I hope this is makeing sense...
Meanwhile, loop 2 has started calling communication function as well and I am getting overlap. I cannot simple set a bit and exit the loop at the end. (It is a big program so you will just have to trust me.)
Is there a way to cache the values needed to be sent to the communications function?
Is there a clean way to exit a loop without it finishing?
Should I be focussing on trying to make the two (in reality 10) different loops NEVER call until all other loops are inactive, or should I be trying to make the communication function able to handle multiple calls?
Thanks in advance for your thoughts.
*****************
"We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW
|
|
|
|
|
|
beautiful... I think that will work. Is it ok that I am not using threads. The call is subscribed to an event so I am not actually creating a new thread.
I will try it and get back.
Thanks,
Dwayne
*****************
"We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW
|
|
|
|
|
Yes its ok that you are not using threads. Mutex works on single threaded applications as well.
|
|
|
|
|
As Peter says, you can use a Mutex. But if you don't need to synchronize between processes, you're better of using lock:
public sealed class MyClass
{
internal void Foo()
{
lock(this)
{
}
}
internal void Bar()
{
lock(this)
{
}
}
}
"God doesn't play dice" - Albert Einstein
"God not only plays dice, He sometimes throws the dices where they cannot be seen" - Niels Bohr
|
|
|
|
|
Hello all nice coders Please can you help me? I need to display an animated gif in a windows form.. is it posible? if it is.. how do i do it?
Please help.. thx
|
|
|
|
|
I have a CheckedListBox that is bound to a DataSet. I have the DisplayValue set to a description field (string) and the ValueMember set to an ID field (int). How can I traverse through the CheckedListBox to find out the values (both DisplayValue and ValueMember values) of the items that are checked. I've tried using a foreach() loop but I get a compiler error since foreach can not operate on a CheckedListBox control. Thanks in advanced...
|
|
|
|
|
are you tried some thing like that
<code>
for(int i=0;i<<checkedListBox1.Items.Count;i++)
{
if(checkedListBox1.GetItemChecked(i))
{
//do somthing
}
}
</code>
MCAD
|
|
|
|
|
Hi,
I'm working with c# in pocket pcs and i have to send and receive some data from a pocket pc (rz1710) to a palm (zire 31). Has anyone faced a problem like this? Can anyone help me giving some tip ? Any help will be welcomed :}
Thanks in advance
Wiler Coelho
|
|
|
|
|
As a continuation of this thread on transparent panels, I've come to an interesting dilema. I'm interested in having a browser window with overlaying transparent panels. The trouble I'm finding is in finding and utilizing a way to Invalidate the browser window such that it's child controls (the panels) will act 'transparent' and draw the browser contents on their background...similar to the OnPaint and OnPaintBackground events. There is sample code at the link above for a basic project example I've put together. I'll include it below just in case. You will, however, have to re-add the resouces Microsoft.mshtml & the AxSHDocVx components (probably on your toolbox with the Add Components option) If anyone has some thoughts or suggestions I would greatly appreciate it! I basically just want a way to 'draw boxes on top of' a web browser. Thanks again!
~rcurrie
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
using mshtml;<br />
<br />
namespace WindowsApplication3<br />
{<br />
public class Form1 : System.Windows.Forms.Form<br />
{<br />
private System.Windows.Forms.Label label3;<br />
private System.Windows.Forms.Label label1;<br />
<br />
private bool LeftMouseDown = false;<br />
private Point MouseDownPos;<br />
private Rectangle DragRect;<br />
private ArrayList FinalRects;<br />
private AxSHDocVw.AxWebBrowser axWebBrowser1;<br />
<br />
private System.ComponentModel.Container components = null;<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
this.axWebBrowser1.Navigate("http://www.msnbc.com");<br />
<br />
this.MouseDownPos = new Point( 0,0 );<br />
this.FinalRects = new ArrayList();<br />
<br />
this.SetStyle(System.Windows.Forms.ControlStyles.SupportsTransparentBackColor, true);<br />
this.SetStyle(System.Windows.Forms.ControlStyles.AllPaintingInWmPaint, true);<br />
this.SetStyle(System.Windows.Forms.ControlStyles.DoubleBuffer, true);<br />
this.SetStyle(System.Windows.Forms.ControlStyles.UserPaint, true);<br />
}<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if (components != null) <br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
<br />
#region Windows Form Designer generated code<br />
private void InitializeComponent()<br />
{<br />
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));<br />
this.label3 = new System.Windows.Forms.Label();<br />
this.label1 = new System.Windows.Forms.Label();<br />
this.axWebBrowser1 = new AxSHDocVw.AxWebBrowser();<br />
((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).BeginInit();<br />
this.SuspendLayout();<br />
this.label1.BackColor = System.Drawing.Color.Transparent;<br />
this.label1.Dock = System.Windows.Forms.DockStyle.Fill;<br />
this.label1.Location = new System.Drawing.Point(0, 0);<br />
this.label1.Name = "label1";<br />
this.label1.Size = new System.Drawing.Size(400, 400);<br />
this.label1.TabIndex = 1;<br />
this.label1.Paint += new System.Windows.Forms.PaintEventHandler(this.label1_Paint);<br />
this.label1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.label1_MouseUp);<br />
this.label1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.label1_MouseMove);<br />
this.label1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label1_MouseDown);<br />
this.label3.BackColor = System.Drawing.Color.Transparent;<br />
this.label3.Controls.Add(this.label1);<br />
this.label3.Location = new System.Drawing.Point(188, 32);<br />
this.label3.Name = "label3";<br />
this.label3.Size = new System.Drawing.Size(400, 400);<br />
this.label3.TabIndex = 0;<br />
this.label3.Paint += new System.Windows.Forms.PaintEventHandler(this.label3_Paint); <br />
this.axWebBrowser1.Dock = System.Windows.Forms.DockStyle.Fill;<br />
this.axWebBrowser1.Enabled = true;<br />
this.axWebBrowser1.Location = new System.Drawing.Point(0, 0);<br />
this.axWebBrowser1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axWebBrowser1.OcxState")));<br />
this.axWebBrowser1.Size = new System.Drawing.Size(819, 476);<br />
this.axWebBrowser1.Controls.Add(label3);<br />
this.axWebBrowser1.TabIndex = 1;<br />
this.axWebBrowser1.Invalidated += new InvalidateEventHandler(axWebBrowser1_Invalidated);<br />
this.axWebBrowser1.Validated += new EventHandler(axWebBrowser1_Validated);<br />
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
this.BackColor = System.Drawing.SystemColors.Control;<br />
this.ClientSize = new System.Drawing.Size(819, 476);<br />
this.Controls.Add(this.axWebBrowser1);<br />
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;<br />
this.MaximumSize = new System.Drawing.Size(825, 500);<br />
this.MinimumSize = new System.Drawing.Size(825, 500);<br />
this.Name = "Form1";<br />
this.Text = "Form1";<br />
((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).EndInit();<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
<br />
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new Form1());<br />
}<br />
<br />
protected override void OnPaintBackground(PaintEventArgs pevent)<br />
{<br />
base.OnPaintBackground(pevent);<br />
}<br />
<br />
private void label1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if( e.Button == MouseButtons.Left )<br />
{<br />
Console.WriteLine("Panel2_MouseDown");<br />
MouseDownPos = new Point(e.X, e.Y); <br />
LeftMouseDown = true;<br />
DragRect = new Rectangle(e.X, e.Y, 0, 0);<br />
this.label1.Invalidate();<br />
} <br />
}<br />
<br />
private void label1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if( e.Button == MouseButtons.Left )<br />
{<br />
Console.WriteLine("Panel2_MouseMove");<br />
DragRect = CalcDragRect(e.X, e.Y);<br />
this.label1.Invalidate();<br />
} <br />
}<br />
<br />
private void label1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if( LeftMouseDown )<br />
{<br />
Console.WriteLine("Panel2_MouseUp");<br />
LeftMouseDown = false;<br />
DragRect = CalcDragRect(e.X, e.Y); <br />
this.label1.Invalidate();<br />
FinalRects.Add(DragRect);<br />
}<br />
}<br />
<br />
private void label1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
if( LeftMouseDown )<br />
{<br />
Pen pen = new Pen(Color.Blue);<br />
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;<br />
DrawRect(e.Graphics, DragRect, pen);<br />
pen.Dispose();<br />
}<br />
}<br />
<br />
private void label3_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
foreach( Rectangle rect in FinalRects )<br />
{<br />
DrawRect(e.Graphics, rect, Pens.Red);<br />
}<br />
}<br />
<br />
public void DrawRect(Graphics g, Rectangle rect, Pen pen)<br />
{<br />
if (rect.Width == 0 && rect.Height == 0) <br />
{<br />
g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Y + (float)0.01);<br />
}<br />
else if (rect.Width > 0 && rect.Height == 0) <br />
{<br />
g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y);<br />
}<br />
else if (rect.Width == 0 && rect.Height > 0) <br />
{<br />
g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Bottom);<br />
}<br />
else<br />
{<br />
g.DrawRectangle(pen, rect);<br />
}<br />
}<br />
<br />
private System.Drawing.Rectangle CalcDragRect(int mouseX, int mouseY)<br />
{<br />
return Rectangle.FromLTRB( System.Math.Min(mouseX, MouseDownPos.X),<br />
System.Math.Min(mouseY, MouseDownPos.Y),<br />
System.Math.Max(mouseX, MouseDownPos.X),<br />
System.Math.Max(mouseY, MouseDownPos.Y) <br />
);<br />
}<br />
<br />
private void axWebBrowser1_Invalidated(object sender, InvalidateEventArgs e)<br />
{<br />
}<br />
<br />
private void axWebBrowser1_Validated(object sender, EventArgs e)<br />
{<br />
}<br />
}<br />
}<br />
|
|
|
|
|
Hi!
Is anyone familiar with VTK (Visualization ToolKit)? I have a major problem using it with windows forms:
I have a windows form, wich is MDIParent, built with C#.
I have another window built with vtkRenderWindow and I want it to appear inside the windows form (as a child window).
Has anyone done this? How?
Pleeeeeease help me!!!!
Patrícia Gonçalves
|
|
|
|
|
I am trying to use VTK from C# code. Did you figure out a way for this? I also need to keep the code cross platform (may be with mono.net). Any suggestions / advice, will be of great help.
Thanks,
|
|
|
|
|
Hi!
I used vtkdotnetwrap, a wrapper for VTK and C# developped by two researchers from the University of West Bohemia (Czech Republic).
You can download it here: http://herakles.zcu.cz/research/vtk.net/.
|
|
|
|
|
|
how can i load a crystal report using dataset with two tabes
the tables should not duplicate
i need practical example
|
|
|
|
|
I've been asked to setup a webpage to use to change passwords. That's the easy part... the tricky part is that I have to run the password through a rule check. It can't be a dictionary word, has to be 8 characters, must have a number in it... etc etc. Anyone know of an easy way to do this? I'm just figuring that this has been done so many times before, there has got to be something already implemented that I can use.
[Edit] I have googled, but I'm not sure what to google for... password rule doesn't get me anywhere [/Edit]
// TODO: Write code.
|
|
|
|
|
Check this out
http://www.thecodeproject.com/csharp/PasswordDialog.asp
Live Life King Size
Alomgir Miah
|
|
|
|
|
Thanks for the link. that was interesting, but not quite what I'm looking for. The article states: "This dialog can be easily extended to add rules to force a minimum size, and even force a combination of case sensitive letters, numbers and punctuation, but that is beyond the scope of this article."
It's this extra stuff that I'm looking to find code for. I could easily write it myself, but I figure someone else has already done this for me. I'm looking for a library or premade class that checks a password against a given dictionary, plus customizable numbers and punctuation rules.
// TODO: Write code.
|
|
|
|
|
|
Another kewl link, but I couldn't find anything about checking a given password against a dictionary in that article.
// TODO: Write code.
|
|
|
|
|