|
In VS 2003, I used CaptionText in DataGrid control. I have migrated my form
in VS 2005 using DataGridView. Does DataGridView has CaptionText property.
How do I accomplish this task if the property does not exist? Any alternate
way of setting CaptionText or Title of the DataGridView?
Help appreciated.
Thanks
|
|
|
|
|
hi,
how can i get the selected text from address bar in Internet Explorer programe.
i try slove these problem use hook techel but i fail.
can anyone help me......
|
|
|
|
|
I cant seem to get this code to work. I need populate a combobox with items that have separate values. For instance: When the user selects "item" within the combobox the "value" associated with that item will be displayed in a textbox.
private void Form1_Load(object sender, System.EventArgs e)
{
ComboBox c = new ComboBox();
c.Items.Add(new MyItem("Item", "Value"));
textBox1.Text = ((MyItem)c.SelectedItem).Content;
}
class MyItem
{
private string item; // String to show in the ComboBox
private string val; // String to show in the TextBox
public MyItem(string i, string v)
{
item = n;
val = v;
}
public override string ToString()
{
return item;
}
public string Content
{
get
{
return val;
}
}
}
It doesn't seem to like this bit of code:
textBox1.Text = ((MyItem)c.SelectedItem).Content;
Error: Object Reference not set to an instance of an object
Any help would be appreciated.
Thanks
-- modified at 12:54 Friday 2nd September, 2005
|
|
|
|
|
That is because the SelectedItem property is null, as the user has not yet selected a value.
You have to wait until the user has selected a value before you can check what the users selected.
---
b { font-weight: normal; }
|
|
|
|
|
Sometimes it is that easy. Thanks for the help
|
|
|
|
|
All of my efforts to add items to display in the combobox fail; I've added items using the IDE in VS2003 (String Collection Editor) or programtically and all I get is an empty drop down list that gets longer. The project compiles and I get no errors but my application only shows an empty drop down list. Can someone please tell me what I'm doing wrong?
|
|
|
|
|
I had this problem for awhile - it was due to McAfee virus scan "Buffer Overflow protection". McAfee had a fix on thier site.
If this is not your problem, sorry.
|
|
|
|
|
Thank you so very much for your help; you were dead on target. I disabled the overflow protection and the code works. Now all I have to do is go around and pick up all my torn hair.
|
|
|
|
|
Glad I could help. I had a bunch of code across my network suddenly generating empty List & Combo boxes. My hair still hasn't grown back.
|
|
|
|
|
has anyone come across an implementation of UNIX style wildmat pattern matching C#. I have searched all over but couldnt seem to find anything.
|
|
|
|
|
Not that I know of. The .NET framework class library has full support for regular expressions, though, in the System.Text.RegularExpressions namespace.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
how can i find out the location of the current class?
would application.startup path work?
|
|
|
|
|
Classes don't necessary reside in a directory. The code file for the class does, sure, but that may not be what you want. Application.StartupPath will give you the directory from which the executable started, excluding the file name of the executable.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
System.Reflection.Assembly.GetExecutingAssembly().Location
|
|
|
|
|
System.Reflection.Assembly.GetEntryAssembly().Location
|
|
|
|
|
how i can i remove all the chr(10) and all the chr(13) at the end of a string.
|
|
|
|
|
To remove newline from the end of string or other chars from the end of string
int pos=textBox1.Text.LastIndexOf(Environment.NewLine);
if (pos !=-1)
{
string text;
text=textBox1.Text.Remove(pos,Environment.NewLine.Length);
textBox1.Text=text;
}
Note: check the pos+length to insure that this he end of
string not just last newline in string
MCAD
-- modified at 10:51 Friday 2nd September, 2005
|
|
|
|
|
myText = myText.Replace("\r\n", "\r");
|
|
|
|
|
You could do a couple things: find the index of each undesired character using theString.IndexOf method, then remove that character using theString.Remove(index, 1). This method, while fairly simple to do, will cause lots of string allocations; for each string.Remove call, a new string will be created. Another way of doing this is to create a System.Text.StringBuilder using your string, then doing a strBuilder.Replace call to replace undesired characters with empty characters.
Perhaps the most efficient way of doing this would be to use a regular expression to swap out the undersireable characters from the end of the string. If you need help creating a regular expression, I recommend this website[^].
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
The tab character is chr(9). I assume that you want to remove the newline combination CR+LF, e.g. chr(13)+chr(10).
One way is to look for it at the end of the string, and remove them as long as there are any:
while (myString.EndsWith(Environment.NewLine)) myString = myString.Substring(0, myString.Length - Environment.NewLine.Length);
This works fine if there is just one or a few newline at the end of the string. If you expect to encounter a lot of newlines, you may want to find out how many there are before you remove them, as string manipulations are relatively slow.
---
b { font-weight: normal; }
|
|
|
|
|
Who can tell me how to create and delete data tables?
I want to manage Access database using ADO.NET with C#.
|
|
|
|
|
//create the database connection
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\db1.mdb");
//create the command object and store the sql query
OleDbCommand aCommand = new OleDbCommand(CREATE_TABLE_STATEMENT, aConnection);
try
{
aConnection.Open();
aCommand.ExecuteNonQuery();
//close the connection Its important.
aConnection.Close();
}
//Some usual exception handling
catch(OleDbException e)
{
Console.WriteLine("Error: {0}", e.Errors[0].Message);
}
}
}
|
|
|
|
|
Hi Every body
I have a usercontrol (Named DatePicker) with a property called 'Date'.This is the syntax of this property :
[Category("Date Info"),Bindable(true)]
public string Date
{
get
{return this.dateString;}
set
{this.dateString = value;}
}
This control also have some string properties (Day,Year and month) without '[Bindable(true)]'Attribute.I use this user control and bind the 'Date' property of this control to a string column of a DataView in my form :
this.datePicker1.DataBindings.Add("Date",this.dvDataSource,"Birthday");
When I delete all rows of dataview whith this code :
this.BindingContext[this.dvDataSource].RemoveAt(this.BindingContext[this.dvDataSource].Position);
and then try to add a new row using the following code,
this.BindingContext[this.dvDataSource].AddNew();
I receive the following Exception :
"DataBinding could not find a row in the list that is suitable for all bindings"
Note :
When I comment the line of code that contains instruction for Binding this property, everything works ok.I bound some other controls (Like DataGrid and TextBox) to the other columns of DataView.They haven't any problem !!
Please help me if anyone knows the answer.
Best Regards.
[ _ Always there is another way _ ]
|
|
|
|
|
I want to communicate two persons, which are on LAN, by voice using IP Address and broadcasting (Conferencing) also. what are the suitable ways to get this done and how.
1. DirectPlay 9.0 Managed
2. UDP Sockets
DirectPlay 9.0 is now obselete according to documentation what is the alternate to this one. If you have any code, ebook or any resource which you can share, send me please.
Thank you
Zeeshan
|
|
|
|
|
Well, Microsoft is "obsoleting" DirectPlay (along with DirectMusic, DirectInput, ...basically everything except Direct3d) in favor of using Windows APIs to accomplish these things. So if you're looking to do communication in a LAN, as long as both client and server are .NET based, then I'd recommend using .NET remoting. There are many examples on this site on how to use .NET remoting.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|