|
override OnDragEnter on the TreeView and change the DropEffect
eg
protected override void OnDragEnter(DragEventArgs drgevent)
{
TreeViewDataFormat dragData = (TreeViewDataFormat) drgevent.Data.GetData(typeof(TreeViewDataFormat));
if (dragData != null)
{
//Do sone stuff
drgevent.Effect = DragDropEffects.Move;
}
}
|
|
|
|
|
Well, I anwered my own question.
Should anyone else chance to search for an answer on how to get drop highlights on tree view controls, look no further than Tree View Common Control.
|
|
|
|
|
hi, when I use this bit of code to get the number of files with the extensions ".mp3, .wma, and .wav" as follows:
int number_of_files = Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*.mp3;*.wma;*.wav", SearchOption.AllDirectories).GetLength(0);
it doesn't return any results. (the number_of_files integer is still 0). I tried this using only *.mp3 and got some results. Why doesn't this work? Am I not supposed to use the semi-colon symbol? IF so which one am I supposed to use? Thanks for your help.
|
|
|
|
|
I think second parameter is a simple pattern, not a regexp.
You can't do things like *.mp3|*.mpg
|
|
|
|
|
so what can I do? I'd prefer to not have to have multiple lines as when I eventually have to add found file strings to an array, it'll be somewhat confusin and if there's another way, needless. any ideas? thanks again.
|
|
|
|
|
Write a method like this:
<br />
public void findFiles(string where, bool recurse, params string[] what){ }
so you can invoke without arrays:
<br />
findFiles("c:\\", true, "*.mp3", "*.avi");<br />
findFiles("d:\\", false, "*.mp3");
and so on.
hope this helps
|
|
|
|
|
Hi Everyone,
I am facing a problem while using DropDownList. Actually I am retrieveing company name from Sql server and displaying on DropDownList (value + id).
If I select DropDownList(just like combo box), it displays me 1st records corresponding to that record(ID). But if I click 2nd,3rd and fourth and so on from DropDownList company name , every time it displays me only 1st record on textbox.
//////////////This is server side program(Update.aspx)//////////////
<%@ Page language="c#" Codebehind="Update.aspx.cs" AutoEventWireup="false" Inherits="Myprogram.Update" %>
Select Company Name:
| asp:DropDownList id="DropDownList1" AutoPostBack="True"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" runat="server"
Width="160px" Height="16px"
DataTextField="Display" DataValueField="Value">
/asp:DropDownList>
| Customer Name:
| <asp:textbox id="txtCustomerName" runat="server" width="160px">
|
/////////Update.aspx.cs////////////
protected void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(this.SelectedItemCombo)
{
DetailsOfRecords();
}
}
protected void DetailsOfRecords()
{
thisConnection.Open();
thisCommand = thisConnection.CreateCommand();
thisCommand.CommandText = " SELECT * from Customers where CustomerID=" + this.DropDownList1.SelectedValue.ToString();
thisReader = thisCommand.ExecuteReader();
while(thisReader.Read())
{
string strID = thisReader["CustomerID"].ToString();
if(strID == this.DropDownList1.SelectedValue.ToString())
{
this.txtCustomerName.Text = thisReader["CustomerName"].ToString();
this.txtCompany.Text = thisReader["Company"].ToString();
}
}
thisReader.Close();
thisConnection.Close();
}
|
|
|
|
|
where is your databind() ? in page_load ?
if I understand your problem, I'm quite sure you've not checked if ispostback before databind().
try (in Page_Load):
<br />
if(IsPostBack == false) {<br />
<br />
DropDownList1.DataBind();<br />
}<br />
|
|
|
|
|
Thanks for solving my one problem.
But I am still facing problem. If I select company name from Dropdownlist it does not showing me corresponding record on the textbox(like customer name,address,phone number and so on.
protected void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(this.SelectedItemCombo)
{
DetailsOfRecords();
}
}
protected void DetailsOfRecords()
{
thisConnection.Open();
thisCommand = thisConnection.CreateCommand();
thisCommand.CommandText = " SELECT * from Customers where CustomerID=" + this.DropDownList1.SelectedValue;
thisReader = thisCommand.ExecuteReader();
while(thisReader.Read())
{
string strID = thisReader["CustomerID"].ToString();
if(strID == this.DropDownList1.SelectedValue.ToString())
{
this.txtCustomerName.Text = thisReader["CustomerName"].ToString();
this.txtCompany.Text = thisReader["Company"].ToString();
this.txtEmailAddress.Text = thisReader["Email"].ToString();
}
}
}
|
|
|
|
|
hum...
1- if that snippet is in a codebehind, than your class inherits from System.Web.UI.Page which does not contains SelectedItemCombo ). So the question is: what is SelectedItemCombo ?
2- doing sql like that in callbacks is a bad idea
3- doing sql without try{}catch{}finally{} is even worst
4- replace while(thisReader.Read()) with: if(thisReader.Read()): is less confusing. But: why not DataSet ?
5- replace if(strID == this.DropDownList1.SelectedValue.ToString()) with if(strID.Equals(this.DropDownList1.SelectedValue.ToString()))
hope this helps
|
|
|
|
|
Thanks for your help.
bool SelectedItemCombo. Actually I have ready made this program in C#(winform) So where I used it.
Once I remove it from my program in ASP.NEt it is working fine.
Once again Thanks.
|
|
|
|
|
I have a search method that calls it's self until a condition is true. Is this wrong?
private void TriggerSearch()
{
*** other misc code ***
if(!blnTriggerFileWritten)
{
TriggerSearch();
}
}
Thanks.
www.lovethosetrains.com
|
|
|
|
|
It's not wrong, but could cause deadlocks if the condition is never true. Also, recursive functions are less efficient than a while loop because each function call in a recursive function must be added to a method call stack, whereas while loops do not.
while(blnTriggerFileWritten == false)
{
blnTriggerFileWritten = ...;
}
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Who is Jewish, the Trivia Game!
Judah Himango
|
|
|
|
|
It depends on what you're trying to do. The most readable version of a binary search is recursive. You should however be aware that there's overhead involved in the additional calls and that as a result the recursive version will take longer to execute than the nonrecursive one. If performance isn't an issue however the recrusive version will be easier to understand and maintain.
|
|
|
|
|
Thanks for the input. Was working a 'C' port and the other programmer was surprised that I could call my function from within my function. I will relook at the code and probably impliment your suggestions. Thanks again.
www.lovethosetrains.com
|
|
|
|
|
How could i validate a unicode string
Thanks
|
|
|
|
|
|
Good find.
"
Validating Unicode Characters
Use the following code to validate Unicode characters in a page.
using System.Text.RegularExpressions;
. . .
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Name must contain between 1 and 40 alphanumeric characters
// and (optionally) special characters such as apostrophes
// for names such as O'Dell
if (!Regex.IsMatch(Request.Form["name"],
@"^[\p{L}\p{Zs}\p{Lu}\p{Ll}\']{1,40}$"))
throw new ArgumentException("Invalid name parameter");
// Use individual regular expressions to validate other parameters
. . .
}
}
The following explains the regular expression shown in the preceding code:
^ means start looking at this position.
\p{ ..} matches any character in the named character class specified by {..}.
{L} performs a left-to-right match.
{Lu} performs a match of uppercase.
{Ll} performs a match of lowercase.
{Zs} matches separator and space.
'matches apostrophe.
{1,40} specifies the number of characters: no less than 1 and no more than 40.
$ means stop looking at this position.
"
/\ |_ E X E GG
|
|
|
|
|
Hi all,
can someone post a snippet of code that draws a rectangle of 2x3 inches ? I mean something that on
every Graphics (and then with every sort of dpi) is 2x3 inches.
I'm getting mad whit this....
please help !
thanks.
|
|
|
|
|
I don't see how that would even be possible. To do it, in addition to knowing the size and type of a monitor to get the approximate screen size (ie 17" crt is about 16" usable), you'd need to know the exact position they adjusted the hieght and width controls to. Beyond that, if you did do this you'd create something that was completely unusable for anyone who, for bragging rights or due to poor vision, is using a projection screen as a primary display.
|
|
|
|
|
I don't see why not.
Infact, I've found how to do it:
g.PageUnit = GraphicsUnit.Millimeter;<br />
g.DrawRectangle(Pens.Black, 50, 50, 50, 50);
does exactly what I need: without care of dpi draws in inches/millimeters/whatever.
|
|
|
|
|
I am using Microsoft's Message Queue and want to get the ID of the Message I just placed in the Q. Reading a few of the examples I have found it says you can do a simple:
mq.Send(msg, Ticket);
string id = mq.Id.ToString();
All this does is return me a Guid with all zero's in it.
I open up Message Q and see my package there. The 'Label' on the Package is all zero's, however, the ID is an actual Guid.
I have tried 'Label' instead of 'Id' and still nothing.
I really need to get that ID of that package I just inserted into Q for processing.
Any help would be appreciated.
Steve Welborn
Software Architect
|
|
|
|
|
|
DOH!
Your right, worked great. Thanks leppie!
Steve Welborn
Software Architect
|
|
|
|
|
I made this with xacc ide...
apparently it didn't make it to the clip board. It was really cooL!
/\ |_ E X E GG
|
|
|
|