|
To use foreach with SelectedIndices
foreach(int i in listBox1.SelectedIndices)
{
MessageBox.Show(listBox1.Items[i].ToString());
}
this will get the selected items from listbox
MCAD
|
|
|
|
|
I am using a DataGrid on an ASP page and have enabled the EditCommand. When editing the textbox that comes up upon clicking Edit, and upon clicking Update, the TextBox does not contain the edited text, but instead the original text. What gives? Any ideas?
private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
TextBox newdesc = (TextBox)e.Item.Cells[2].Controls[0];
String desc = newdesc.Text;
Response.Write(desc);
DBImage dbImage = new DBImage(ConfigurationSettings.AppSettings["ConnectString"]);
dbImage.UpdateDesc(id,desc);
this.DataGrid1.EditItemIndex = -1;
this.DataGrid1.DataBind();
}
|
|
|
|
|
In your line dbImage.UpdateDesc(id, desc) where does the variable id get set to specify which record gets updated?
|
|
|
|
|
You will have to call EndEdit before DataGrid1_UpdateCommand gets executed.
A little code snippet might help,
CurrencyManager currencyManager = (CurrencyManager) this.dataGridFormulaFee.BindingContext[this.dataTable];
if (currencyManager != null)
{
currencyManager.Position = this.currentGridRow;
DataGridColumnStyle dataGridColumnStyle = this.dataGridFormulaFee.TableStyles[0].GridColumnStyles[0];
this.dataGridFormulaFee.EndEdit(dataGridColumnStyle, this.currentGridRow, false);
}
Live Life King Size
Alomgir Miah
|
|
|
|
|
I have a ASP.Net web application must be registered with us before it can be used. I want to create a shortcut to the registration process that is placed in the Start Menu. Once the registration process is done, I want the shortcut to be removed from the Start Menu. Does anyone know how I might do this? Thanks in advance.
|
|
|
|
|
|
Do you mean delete the registration files? The registration will be done on a client PC so this process has to be automated. Right now I am using the File System Editor in VS.Net to create the shortcuts during installation. The properties for the shortcut does not contain anything to delete the shortcut or files that it is pointing to. I don't need to delete the registration files, just a way to automatically delete the shortcut from the Start->Programs menu after a successful registration. Thanks.
|
|
|
|
|
The start menu itself is nothing more than a set of folders filled with shortcuts. You can programmatically delete files from it just as you would anywehre else on the drive.
|
|
|
|
|
I have a toolbar added to Windows Form and docked top.
The problem is when the Form is resized, the ToolBar buttons appearing at the end gets clipped.
Is there a way to display the toolbar similar to internet explorer where a dropdown appears in such a case. Could somebody point me to some article on this.
Thanks in advance for your help.
Live Life King Size
Alomgir Miah
|
|
|
|
|
Hello,
I have:
protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData) <br />
{ <br />
if(msg.WParam.ToInt32() == (int) Keys.Enter) { <br />
SendKeys.Send("{Return}");<br />
return true; <br />
} <br />
return base.ProcessCmdKey(ref msg, keyData); <br />
}
When I press Enter in the richTextBox, it gives me an exception stating that there is no key word Return. Any ideas?
Thank you
P.S. Is there a way, after you override the ProcessCmdKey, to set it back to it's original form? Because I think richTextBox behaves very funny (on Enter press closes form) because I was tinkering with the CmdKey method.
|
|
|
|
|
I think the SendKeys.Send method doesn't like the expression "{Return}".
Try SendKeys.Send("{ENTER}");
www.troschuetz.de
|
|
|
|
|
|
How come when I press Enter, and I am within richTextBox, my Form closes?
Is there a way insted of sending enter, send a new line?
Thank you
|
|
|
|
|
I have marshalled an imaging library and have recieved the pointer to the image buffer in an IntPtr object. How can I load that image in a System.Drawing.Image or Bitmap object. I would prefer not to use unsafe code unless deemed very necessary.
|
|
|
|
|
|
Hope someone can help me. I want to add two values in a combobox.
It's for players of a team. Now I have done it as follow with an DataSet:
<br />
cbPlayers.DataSource = dsPlayers.Tables["Players"];<br />
<br />
cbPlayers.ValueMember = "PlayerID";<br />
cbPlayers.DisplayMember = "FullName";<br />
This gives a combobox filled with only playernames
But I also would like to include the team name behind the playername in this combobox.
Who can help me out?
|
|
|
|
|
|
If You don't find suitable solution you can create custom
class that have properties that you want and load combobox
by code instead of data binding this way you can control what text will appear in each combobox item
MCAD
|
|
|
|
|
Hi Mohamad,
Is there a way to do it through DataView. I could not find a way to merge columns togather. RowFilter is the only thing you can do.
Live Life King Size
Alomgir Miah
|
|
|
|
|
Hi Alomgir
Sorry i don't understand what you mean can you explain it more?
What i want to say that he can create custom class
which contain properties like PlayerID,FullName
and add it in items collection or use datatable
MCAD
|
|
|
|
|
I understood your solution and I think it will work perfectly.
This is just out of curiosity,
I was just wondering if we can combine column values using DataView.
Live Life King Size
Alomgir Miah
|
|
|
|
|
You Can Create Expression Column That do that
And bind DisplayMenmber to it somthing like that
DataColumn dc=new DataColumn("Test",typeof(System.String)));
dc.Expression="ContactName + (' ')+ CustomerID ";
dataSet21.Customers.Columns.Add(dc);
comboBox1.DataSource=dataSet21.Customers;
comboBox1.DisplayMember=dataSet21.Customers.Columns["test"].Caption;
comboBox1.ValueMember=dataSet21.Customers.CustomerIDColumn.Caption;
MCAD
|
|
|
|
|
Thanx Mohamad. This is the solution for me! But one other thing
This works for me:
dc.Expression = "FullName + (' ')+ TeamName";
But I prefer an outcome like:
FullName [TeamName]
I tried the following but it gives an error:
dc.Expression = "FullName + (' [')+ TeamName" + (']');
How can I achieve this the right way?
|
|
|
|
|
How stupid?
I know it now:
dc.Expression = "FullName + (' [')+ TeamName + (']')";
Thanx anyway...
|
|
|
|
|
Thanks.........
Live Life King Size
Alomgir Miah
|
|
|
|