|
try this
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
try
{
SqlConnection con = new SqlConnection("ur connection string");
con.Open();
SqlDataAdapter da = new SqlDataAdapter("Select * from emp order by Empno where Dept='" + DropDownList1.Value.ToString() + "'",SqlConnection);
//connectdb();
//Cmd.CommandText =
//da.SelectCommand = Cmd;
DataSet ds = new DataSet();
da.Fill(ds,"Emp");
DataGrid1.DataSource = ds.Tables["emp"];
//DataGrid1.DataMember = "Emp";
DataGrid1.DataBind();
}
catch (Exception ex)
{
Response.Write(ex.Message);
Con.Close();
}
|
|
|
|
|
Alright, I'm trying to integerate an IR remote control into one of my apps. I used Spy++ to try to figure out what messages were being sent to the app. The WM_APPCOMMAND message is begin sent. But this message is being sent for the every media key. i read somewhere that you ahve to use GET_APPCOMMAND_LPARAM(lparam) to get the unique media key but i dont know how to implement this in C#. I am currently overloading the WndProc(ref Message m) even and attempting to do something when the message == WM_APPCOMMAND...but again i dont know how to differentiate between the different WM_APPCOMMAND's.... Play...Stop....Next Track....Previous Track....are all the same message...help guys.
-- modified at 0:30 Thursday 22nd December, 2005
|
|
|
|
|
The Message[^] structure that gets passed to the WndProc method has LParam and WParam properties. You need to look into how GET_APPCOMMAND_LPARAM(lparam) is implemented to get the value out of the LParam property.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
figured it out, there is a lparam property in the message structure that i have to interperet AFTER i catch on the wparam property of app_command....a long int get returned. simple switch statement and i got it all working. thanks for your help
|
|
|
|
|
hi
Does anyone here can give me good sites or book recommendations for the customs controls in C#
I want to create custom control for the radio button in the datagrid where I want give the user only one option to select the items from the database
Is custom control for radiobuttonlist in datagrid is possible or not??
thanks in advance
kal13na13
|
|
|
|
|
Hello
I think it's impossible and you should choose your field as boolean and datagrid shows that as CheckBox.
for this in Datagrid TableStyle you should define DataGridBoolColumn.
for additional goto :
Styling with the DataGridColumnStyle, Part 2
Is it usefull ?
|
|
|
|
|
Hi,
I am able to draw line between two points during MouseDown and MouseUp events...
But i ve two problems over it...
1.when i handle the mouse events,the lines arenot drwan immediately...It displays the line only after i chang the focus and return back to the form..
2.The line which i ve drawn should vanish when i draw another line...
How can i do these..
Am new to this graphics section...So kindly help me...
Thanx
|
|
|
|
|
Do you draw your line in OnPaint ? That's the only place to do it. Call Invalidate() in your mouseup to trigger OnPaint.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
ya i did...
Here's the code...
<br />
public void OnPaint(object sender,PaintEventArgs e)<br />
{<br />
Graphics g=e.Graphics; <br />
Pen pen=new Pen(Color.Magenta);<br />
Point p1=new Point(index1,index2);<br />
Point p2=new Point(index3,index4);<br />
g.DrawLine(pen,p1,p2); <br />
} <br />
<br />
public void mouseUp(object sender,MouseEventArgs e)<br />
{<br />
index3=e.X;index4=e.Y; <br />
this.Paint+=new PaintEventHandler(this.OnPaint); <br />
Invalidate();<br />
}<br />
public void mouseDown(object sender,MouseEventArgs e)<br />
{<br />
index1=e.X;index2=e.Y; <br />
}<br />
Kindly help me...
Its very urgent
Thanx
|
|
|
|
|
fyi. i already replied to your other post.
|
|
|
|
|
ya ,i got it....
Thank u.......
|
|
|
|
|
Mahi.Ragava wrote: this.Paint+=new PaintEventHandler(this.OnPaint);
This is bizarre, and totally unnecessary.
This will draw the last line that you drew, the only thing I would change is to set index3 and index4 in mouseDown to be the same as index1 and index2, and then call Invalidate(), and I would handle mousemove, setting index3 and index4 as you go, calling invalidate again ( when the mouse is down ).
Also, I would replace index1-4 with two Point variables.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I am writing some code (for fun) that will display the mouse coordinates in real time on a WinForm. The "e.X, e.Y" coordinate text is displayed next to the position of the cursor. Problem is, every time I move the mouse the graph that I've drawn to "run" the coordinates over
keeps getting re-drawn (flicker?) until I stop moving the mouse-- and then the coordinates are displayed over the graph I've drawn. Is there any way to fix this?
ps- many people have very helpful to my questions --> I am very grateful.
////////////////////////////////////////////////////////////
Here are the relevant code fragments....1)Paint, 2)MouseMove, 3)override OnPaint
///////////////////////////////////////////////////////////
void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics;
g.DrawRectangle(graphPen, xIndent, yIndent, 400,400);
g.FillRectangle(graphBrush, xIndent, yIndent, 400, 400);
g.DrawLine(graphPen, xIndent + 200, yIndent, xIndent + 200, yIndent + 400);
g.DrawLine(graphPen, xIndent, yIndent + 200, xIndent + 400, yIndent + 200);
DrawGraphLines(g);
DrawXYAxes(g);
if(m_bFlag1)
DrawComplexLineA(g);
if(m_bFlag2)
DrawComplexLineB(g);
if(m_bAddFlag)
DrawComplexAdd(g);
}
///////////////////////////////////////////////////////////////////////////
private Point mousePoints;
protected override void OnMouseMove(MouseEventArgs e)
{
// TODO: Add Form1.OnMouseMove implementation
mousePoints = new Point(e.X,e.Y);
Invalidate();
base.OnMouseMove (e);
}
////////////////////////////////////////////////////////////////////////////
protected override void OnPaint(PaintEventArgs e)
{
// TODO: Add Form1.OnPaint implementation
base.OnPaint (e);
Point screen = PointToScreen(mousePoints);
string location = screen.ToString();
e.Graphics.DrawString("[Screen: " + location + "]",
new Font("Arial",8),
SystemBrushes.ControlText,
(PointF)mousePoints);
}
/////////////////////////////////////////////////////////
|
|
|
|
|
Turn on double buffering:
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.ResizeRedraw, true);
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian,
Thanks-- In which/where (method?) do I "turn on double buffering"?
what's "this."? - An instantiated "what"?
I'm a bit behind the learning curve here but very appreciative of your response-- thanks again....
|
|
|
|
|
sorry for the interruption...
just call the method(what christian gave you) on the constructor of your control.
Hope that helps!
|
|
|
|
|
this means the class that the code is written in. You don't need it, actually.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi everybody,
Do anyone knows what is replacement for functions done by Port Class in Compact Framework in .Net Framework 1.1? The Port class is for serial socket communication and can be used to connect to Modem.
denpsia
-- modified at 19:31 Wednesday 21st December, 2005
|
|
|
|
|
Hey there
Any body knows an implemetation of Damerau or Editex algorithm?
Im implementing Damerau algorithm but i have problems.
If some body worked in this or have ported any algorithm, please tell me.
Thanks
Elvio Fernandez
|
|
|
|
|
|
Hi Curtis
Thanks for your time
I already implemeted Leveshtein. My problem is Im new in dynamic programming so sometimes I try to port (to code) several mathematical recursive definitions and.. I lose!!
Actually Im trying to code Editex algorithm (a mix between Levenshtein and phonetic algorithm). Interesting data about this is found in paper "Phonetic String Matching: Lessons from Information Retrieval" by Justin Zobel & Philip Dart
Do you know some url talking about dynamic programming? Some text readable for a human being!!
Thanks
Elvio Fernandez
|
|
|
|
|
Merry Christmas Eve, Elvio!
I headed over to Wikipedia and found from their discussion on Dynamic programming A Tutorial on Dynamic Programming. I read it and it seems <smile>readable for a human being</smile>. It's math-oriented (like they all seem to be, eh?), but nothing insurmountable like advanced topology.
On another note, I read the paper and it sounds like a neat thing. If I have more time this weekend, I'll give a stab at an implementation. Two terms ago I did an information retrieval class in my grad program and really enjoyed it. Based on what I learned there, I've almost completed an article for CodeProject on creating a spellchecker based on M-Trees and Levenshtein distance. I would like to follow that with a document retrieval article using M-Trees and something simple like document content tokenization minus junk words. When time allows, as always!
Hope this finds you and your loved ones well.
Sincerely,
Curtis.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
An Editex implementation. Hope this helps you find your way through dynamic programming!
#region Constructor
public YourClassNameHere()
{
editexGroups = new Hashtable( 24 );
editexGroups[ 'a' ] = new int[] { 0 };
editexGroups[ 'b' ] = new int[] { 1 };
editexGroups[ 'c' ] = new int[] { 2, 9 };
editexGroups[ 'd' ] = new int[] { 3 };
editexGroups[ 'e' ] = new int[] { 0 };
editexGroups[ 'f' ] = new int[] { 7 };
editexGroups[ 'g' ] = new int[] { 6 };
editexGroups[ 'i' ] = new int[] { 0 };
editexGroups[ 'j' ] = new int[] { 6 };
editexGroups[ 'k' ] = new int[] { 2 };
editexGroups[ 'l' ] = new int[] { 4 };
editexGroups[ 'm' ] = new int[] { 5 };
editexGroups[ 'n' ] = new int[] { 5 };
editexGroups[ 'o' ] = new int[] { 0 };
editexGroups[ 'p' ] = new int[] { 7 };
editexGroups[ 'q' ] = new int[] { 2 };
editexGroups[ 'r' ] = new int[] { 4 };
editexGroups[ 's' ] = new int[] { 8, 9 };
editexGroups[ 't' ] = new int[] { 3 };
editexGroups[ 'u' ] = new int[] { 0 };
editexGroups[ 'v' ] = new int[] { 7 };
editexGroups[ 'x' ] = new int[] { 8 };
editexGroups[ 'y' ] = new int[] { 0 };
editexGroups[ 'z' ] = new int[] { 8, 9 };
}
#endregion
#region Editex Distance
public int EditexDistance( string first, string second )
{
first = StringCleaner.NullToEmpty( first ).ToLower();
second = StringCleaner.NullToEmpty( second ).ToLower();
if( ( first == string.Empty && second == string.Empty ) || first == second )
{
return 0;
}
int[,] array = new int[ first.Length + 1, 2 ];
array[ 0, 0 ] = 0;
array[ 1, 0 ] = 1;
array[ 0, 1 ] = 1;
for( int i = 2; i < first.Length + 1; i++ )
{
array[ i, 0 ] = array[ i - 1, 0 ] + d( first[ i - 2 ], first[ i - 1 ] );
array[ i, 1 ] = array[ i - 1, 0 ] + d( first[ i - 2 ], first[ i - 1 ] );
}
int sourceColumn = 0;
int targetColumn = 1;
int left = 0;
int up = 0;
int diag = 0;
for( int i = 1; i < second.Length + 1; i++ )
{
array[ 0, targetColumn ] = ( ( i != 1 )? array[ 0, sourceColumn ] + d( second[ i - 2 ], second[ i - 1 ] ) : 1 );
for( int j = 1; j < first.Length + 1; j++ )
{
left = array[ j, sourceColumn ];
up = array[ j - 1, targetColumn ];
diag = array[ j - 1, sourceColumn ] + r( first[ j - 1 ], second[ i - 1 ] );
if( j > 1 )
{
up += d( first[ j - 2 ], first[ j - 1 ] );
}
else
{
up++;
}
if( i > 1 )
{
left += d( second[ i - 2 ], second[ i - 1 ] );
}
else
{
left++;
}
array[ j, targetColumn ] = StringComparer.Min( left, up, diag );
}
sourceColumn = Math.Abs( sourceColumn - 1 );
targetColumn = Math.Abs( targetColumn - 1 );
}
return array[ first.Length, sourceColumn ];
}
private int d( char a, char b )
{
if( a == 'h' || a == 'w' )
{
return 1;
}
else if( b == 'h' || b == 'w' )
{
return 0;
}
return r( a, b );
}
private int r( char a, char b )
{
if( a == b )
{
return 0;
}
bool inSameGroup = false;
int[] ga = ( int[] ) editexGroups[ a ];
int[] gb = ( int[] ) editexGroups[ b ];
if( ga == null || gb == null )
{
return 0;
}
for( int i = 0; i < ga.Length && !inSameGroup; i++ )
{
for( int j = 0; j < gb.Length && !inSameGroup; j++ )
{
inSameGroup = ( ga[ i ] == gb[ j ] );
}
}
return ( ( inSameGroup )? 1 : 2 );
}
private Hashtable editexGroups;
#endregion
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hey Curtis!!
Thank you very very very much for your time.
Im reading your links on dynamic programing.
Thanks for Editex code!!! Im impatient to test it!!!
Im working on a system based on trademark watching, so I have to test similarity on Trademark names.
Actually, to detect similarity I have a set of algorithm working together (Levenshtein, QGrams, CharMatching, DoubleMetaphone). To test similarity I have several set of words. The first, a Dictionary with 800,000 entries (from http://www.outpost9.com/files/WordLists.html), the second a small Database with 30,000 trademarks (if you want it just tell me).
There are some implementations in sourceforge.net ( search for this packages lucene-1.2-src.zip, phonetics.NET-20050420.zip, secondstring-20030401.tgz, simmetrics.NET-20041111.zip, JSpell)
Also, there are a library for openBSD on this issue libdistance-0.2.1.tar.gz located in http://www.monkey.org/~jose/software/libdistance/
Jose, author of libdistance-0.2.1.tar.gz is a cool guy, Im working with Damerau distance ported from libdistance-0.2.1.tar.gz
Some interesting papers:
- Finding Approximate Matches in Large Lexicons by JUSTIN ZOBEL & PHILIP DART
- Searching trademark databases for verbal similarities by C.J. Fall & C. Giraud-Carrier
- Indexing methods for approximate string matchings by Gonzalo Navarro, Ricardo Baeza-Yates, Erkki Sutinen, Jorma Tarhio
- Guided tour to approximate string matching by Gonzalo Navarro
There are more, but I think those one are most relevant. A lot of papers is found in http://citeseer.lcs.mit.edu/cs
Portal ACM site have a lot of papers but they want you pay for this papers I dont wanna pay for something that belongs to humanity
All algorithms that Im using are ported code from some library located in sourceforge.net , but nobody write something about Editex. Just looking your code I see my error was in first stage of algorithm, I have initialize the cost matrix in a wrong way.
Curtis (again) thanks for your help.
Elvio Fernandez
|
|
|
|
|
Hey, no problem. I had fun playing with Editex and showing it to my geek friends.
Thank you for the leads on the other papers, too. I really enjoy information retrieval as a hobby/research area.
If I can help you with anything else, just post! I lurk about the boards quite often....
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|