|
-> if the user cannot focus the textbox, why not set the ReadOnly textbox property to true?
-> you can also set the focus to another control you want in this code snippet, for instance.
good luck
|
|
|
|
|
Hi
As far as I know you can not force a custom control to lose focus but you can notify its container that it can gain the focus (by making it deisable or readonly ) or you can throw an exception when your text box is getting the focus.
for example:
<br />
protected override void OnEnter(EventArgs e)<br />
{<br />
if(noFocus)<br />
throw new MyTextBoxCantGetFocusException();<br />
}<br />
then you can manage the focus in your container
Regards
|
|
|
|
|
I Found the solution:
bool noFocus = true;<br />
<br />
protected override void OnEnter(EventArgs e)<br />
{<br />
if (noFocus == true)<br />
{<br />
int index = Parent.Controls.IndexOf(this);<br />
Parent.Controls[index - 1].Focus();<br />
}<br />
}
|
|
|
|
|
Goerlandt wrote: int index = Parent.Controls.IndexOf(this);
Parent.Controls[index - 1].Focus();
Hello,
Be carefull if index is "0".
All the best,
Martin
|
|
|
|
|
Hi all,
I am creating a form and in which, the user should have an option to insert symbols in the text box. The symbols include Greek symbols, standard mathematical operators and others stuff. How could i make a user interface such that user selects a symbol from the pop-up window, so the selected symbol value should return into the text box.
|
|
|
|
|
Hi everyone
I am trying to export data from datagrid to excel but gives me this erro"Obect reference not set to instance of the object".here is my code.I am using windows C#.
lblMessage.Text = "";
DataTable dtTransactions = dsTransactions.Tables["Transactions"].Copy();
int[] iColumns = {0,1,2,3,5,6};
RKLib.ExportData.Export objExport = new RKLib.ExportData.Export("Win");
objExport.ExportDetails(dtTransactions,iColumns,Export.ExportFormat.Excel,"C:\\TransactionsInfo.Excel");
lblMessage.Text = "Successfully exported to C:\\TransactionsInfo.Excel";
-- modified at 8:28 Thursday 31st August, 2006
|
|
|
|
|
Response.Clear();
Response.Charset = "";
Response.AddHeader("content-isposition", "attachment;filename=FileName.xls");
Response.ContentType = "application/vnd.ms-excel";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
DataGrid dGrid = new DataGrid();
dGrid.DataSource = Classname.functionname();//this is where u write the stored procedure
dGrid.HeaderStyle.Font.Bold = true;
dGrid.DataBind();
dGrid.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
please help me
|
|
|
|
|
Hi all,
This is hard to explain but I need some sort of Algorythm that will calculate a number for me.
Basically, I am "trying" to build a class that will output a Graph for our web stats, within my code I have got the highest amount that will be shown on the graph, and now I need to set the Y Axis values.
So at the moment, I have the values 0,2,0,90,172
because the highest value is 172 i'd like to some how generate a set of numbers like the following:
0,30,60,90,120,150,180
But since these values constantly change, I need some fancy way of calculating them.
Anyone have any idea's?
The reason why I ask, is because the Graph size will be 200hx700w (pixels) and regardless of the
results I want them to fit without any further coding.
Thanks
Gav
|
|
|
|
|
Gavin Roberts wrote: because the highest value is 172 i'd like to some how generate a set of numbers like the following:
0,30,60,90,120,150,180
Round the highest number to be a multiple of 10, and then create a set with n steps with: number / n
Example:
highest value = 154
-> maxnumber = (int)(154 / 10) * 100 + 10
(But this will only work reliable in the range of 10-100 - I can write an algorithm for you that will work on any kind of numbers, up to a million and above, but I have no time right now. I might write it later for you if you need it )
steps: n steps (e.g. 5)
-> step = maxnumber / n
then you can create your steps like this:
0, step, 2*step, 3*step, ... maxnumber
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
if I understood the question correctly:
take the highest number (in our example its 172) and do the following:
172 / 10 = 17.2 -- but if it is "int" we will get --> 17
17 + 1 = 18 // add 1
18 * 10 = 180 // multiple by 10
and you rounded up the heighest number.
so the algorithm is:
roundUP(int x)
{
int result;
result = x/10;
result++;
result*=10;
if(result > 200)
result = 200;
return result;
}
it seems to me a pretty efficint way to calculate, unless I didn't understand the question.
hope it helps!
|
|
|
|
|
There is an article here on Codeproject presenting A flexible charting library for .NET[^] that implements the described behaviour. Either use this library or take a look at the source code to see how the autoscaling is accomplished.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
|
Hi guys
I need small help regarding the datagrid.
I need to send data from one ane datagrid to another datagrid by clicking the button from first datagrid to a particular record.
In my first grid i had a text box where i need to enter the integer value in that text box.
So plz let me if any one did this.
please help me
|
|
|
|
|
Hi
Would you please explain your senario a little bit more.I can't get it.
I think that you have a list of enities( say products) and want to add it as a piece of information into another list (say an order items list) and then enter its amount.
If that's the senario let me know
Thnaks
|
|
|
|
|
I have a datagrid in which all menu items are there,in that i ll give the quantity in textbox which is located in datagrid. so when i click add button then that menitem & quantity should be added in another datagrid.
This is my request sir.
Thanking u,
Regards,
Naren.
please help me
|
|
|
|
|
hi guys
i wanna develop a application in c# for my pocket PC to call telecommunication services like (check the balance, summary, and other services which is provided by telecommunication), now what i doing when ever i want to check the balance summary i have to dial the service center No., to solve this problem i will configure everything in my application on time whenever i want i can use my application for those feature, no need to dial
so please solve this problem if any one know about the above mentioned subject
raj
project leader
India
code
-- modified at 8:53 Sunday 3rd September, 2006
code
-- modified at 8:54 Sunday 3rd September, 2006
<
|
|
|
|
|
I think TAPI is helpfull to you.
regards,
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|
|
I have an enum say enum1. It has four fields f1,f2,f3,f4. I have allowed this to be set with multiple values. The enum1 is shown bellow:
public enum enum1
{
f1=0,
f2=1,
f3=2,
f4=3
}
But this allows enum with any combination of values to be set. I want this enum with particular restricted combination (say f1|f2,f2|f3, and f1|f4 only) to be set. How can i accomplish that?
Thanks.
|
|
|
|
|
Hello
You could create a property of the enum1 type
public enum enum1{ f1=0, f2=1, f3=2, f4=3}
private enum1 myEnum1;
public enum1 MyEnum1
{
get ( return myEnum1; }
set
{
if (value == f1 || value == f3)
myEnum1 = value;
else
throw new ArgumentException("Invalid assignment");
}
}
Otherwise you could create different enums
public enum enum1{ f2=1, f4=3}
public enum enum2{ f1=0, f3=2}
for example.
Kind Regards,
John Petersen
|
|
|
|
|
Thank you very much. And from your side i desires for welcome.
|
|
|
|
|
If you intend the enum to allow for OR'd combinations as you imply, you should decorate the enum with the Flags[^] attribute.
This attribute indicates that an enumeration can be treated as a bit field; that is, a set of flags. Bit fields can be combined using a bitwise OR operation, whereas enumerated constants cannot.
Bit fields are generally used for lists of elements that might occur in combination, whereas enumeration constants are generally used for lists of mutually exclusive elements. Therefore, bit fields are designed to be combined with a bitwise OR operation to generate unnamed values, whereas enumerated constants are not. Languages vary in their use of bit fields compared to enumeration constants.
Your code will compile without the Flags attribute, but it helps the compiler, the runtime and other developers understand how the enum is supposed to be used.
|
|
|
|
|
In a method i have two strings first is a property name i.e. "Text" and second is its value "MyName" as well as I have a control on my web form i.e. TextBox1 now on the basis of given string how can I set the TextBox1.Text = "MyName". The problem is I didn't found any property collection with control object and through reflection i can access properties but in that case those were not attached with a perticular control. How can I map the Text property of TextBox control through string "Text"???
|
|
|
|
|
Hi,
I have a lil question about how to change te way the program handle things.
I have a device attached to my serial port.
Thi device can take several commands, and it returns something back which i can read on the screen. But after every command i send to the device, there should be a thread.sleep(1000).
Since i send alot of commands automatically to the device, i rather want it to wait till it gets the info and then send it back.
Because the sleep(1000) isnt always enough. Sometimes it needs a lil more time to reply.
So i want to make an event handler which waits for a reply and than continue.
This is a peace of the code how it looks like:
serialPort = new SerialPort("COM1", 19200, Parity.None, 8, StopBits.One);
serialPort.Write(command);
Thread.Sleep(1000);
serialPort.Write(command);
Thread.Sleep(1000);
serialPort.Write(command);
Thread.Sleep(1000);
serialPort.Write(command);
Thread.Sleep(1000);
Can someone help me how to make an event handler for this?
Thanks in advance!
|
|
|
|
|
Hi,
In Visual Studio 2005 the serial port control has events. And one of them is DataReceived. Try using that event.
Do your best to be the best
|
|
|
|
|
Hi
I think that you can use AsyncCallBackDelegate to do what you want.This way you can run a command Asynchronously and when its done you callback delegate will be executed.You can have a delegate to run your command and in its BeginInvoke moethod you will pass a AsyncCallBackDelegate.
Regards
|
|
|
|