|
Take a look at the NSIS project[^]. Its an easy-to-learn and in my opinion very useful open source system for creation of Windows installers. Among many others the web site provides a code example for Installing the Microsoft .NET Framework[^].
"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
|
|
|
|
|
I am working within a DataGrid and would like to select a whole row when the user clicks anywhere in the row. I am not sure how to accomplish this and would like some direction.
Best of luck,
Michael Baker
|
|
|
|
|
This code will help u to get the whole row of the grid selected when u click a check box in the corresponding rows of the grid. Hope this solves ur issue.
using System;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace solCommon.Web.UI.DataGrid
{
///
/// CheckBoxColumn Derives from DataGrid Column
///
public class DGCheckBoxColumn : DataGridColumn
{
public DGCheckBoxColumn(): base()
{
}
public override void InitializeCell(TableCell cell,
int columnIndex, ListItemType itemType)
{
//let the base class initialize the cell
base.InitializeCell(cell, columnIndex, itemType);
if( itemType == ListItemType.EditItem ||
itemType == ListItemType.Item ||
itemType == ListItemType.AlternatingItem ||
itemType == ListItemType.SelectedItem ||
itemType == ListItemType.Header)
{
CheckBox checkbox = new CheckBox();
//assign an ID that we can use to find the control later
//we don't want to add a normal checkbox to the header.
checkbox.ID = (itemType==ListItemType.Header)? "checkboxHead": "checkboxCol";
cell.Controls.Add(checkbox);
}
}
public Int32[] SelectedIndexes
{
get
{
ArrayList selectedIndexList = new ArrayList();
//iterate each DataGridItem and find our checkbox
foreach( DataGridItem item in this.Owner.Items )
{
CheckBox chkBox =
(CheckBox) item.FindControl("checkboxCol");
//If it's selected then add it to our ArrayList
if ( chkBox != null && chkBox.Checked )
{
selectedIndexList.Add( item.ItemIndex );
}
}
return (Int32[])selectedIndexList.ToArray(typeof(
System.Int32 ) );
}
}
public object[] SelectedDataKeys
{
get
{
//Just iterate each of the selectedindexes and
//match it up to the datakey field
ArrayList dataKeyList = new ArrayList();
//make sure the datakeys have some values
if(this.Owner.DataKeys.Count > 0)
{
foreach( Int32 selectedIndex in SelectedIndexes )
{
object DataKey =
(this.Owner.DataKeys[selectedIndex].ToString());
dataKeyList.Add(DataKey);
}
}
return (object[])dataKeyList.ToArray(typeof( object ) );
}
}
public static void RegisterClientCheckEvents(Page pg, string formID)
{
string strCol = GetCheckColScript();
string strHead = GetCheckHeadScript();
if(!pg.IsClientScriptBlockRegistered("clientScriptCheckAll"))
pg.RegisterClientScriptBlock("clientScriptCheckAll", strHead.Replace("[frmID]",formID));
if(!pg.IsClientScriptBlockRegistered("clientScriptCheckChanged"))
pg.RegisterClientScriptBlock("clientScriptCheckChanged", strCol.Replace("[frmID]",formID));
RegisterAttributes(pg);
}
private static void RegisterAttributes(Control ctrl)
{
foreach (Control wc in ctrl.Controls)
{
try
{
if ( wc.HasControls() )
RegisterAttributes(wc);
CheckBox chk = (CheckBox)wc;
if (chk != null && chk.ID == "checkboxCol")
{
chk.Attributes.Add("onclick","CheckChanged()");
}
else if ( chk != null && chk.ID == "checkboxHead")
{
chk.Attributes.Add("onclick","CheckAll(this)");
}
}
catch
{
}
}
}
private static string GetCheckColScript()
{
string strScript;
strScript= " ";
strScript+=" function CheckAll( checkAllBox )";
strScript+=" {";
strScript+=" var frm = document.[frmID];";
strScript+=" var ChkState=checkAllBox.checked;";
strScript+=" for(i=0;i< frm.length;i++)";
strScript+=" {";
strScript+=" e=frm.elements[i];";
strScript+=" if(e.type=='checkbox' && e.name.indexOf('checkboxCol') != -1)";
strScript+=" e.checked= ChkState ;";
strScript+=" }";
strScript+=" }";
strScript+=" ";
return strScript;
}
private static string GetCheckHeadScript()
{
string strScript="";
strScript= "";
strScript+="function CheckChanged()";
strScript+="{";
strScript+=" var frm = document.[frmID];";
strScript+=" var boolAllChecked;";
strScript+=" boolAllChecked=true;";
strScript+=" for(i=0;i< frm.length;i++)";
strScript+=" {";
strScript+=" e=frm.elements[i];";
strScript+=" if ( e.type=='checkbox' && e.name.indexOf('checkboxCol') != -1 )";
strScript+=" if(e.checked== false)";
strScript+=" {";
strScript+=" boolAllChecked=false;";
strScript+=" break;";
strScript+=" }";
strScript+=" }";
strScript+=" for(i=0;i< frm.length;i++)";
strScript+=" {";
strScript+=" e=frm.elements[i];";
strScript+=" if ( e.type=='checkbox' && e.name.indexOf('checkboxHead') != -1 )";
strScript+=" {";
strScript+=" if( boolAllChecked==false)";
strScript+=" e.checked= false ;";
strScript+=" else";
strScript+=" e.checked= true;";
strScript+=" break;";
strScript+=" }";
strScript+=" }";
strScript+=" }";
strScript+=" ";
return strScript;
}
}
}
Vipin
|
|
|
|
|
I have a main form that is set to auto scroll so that when lower screen resoloutions are used, scroll bars are provided. The controls are not getting set back to position 0,0 but are displaying where ever the last scroll bar displayed the previouse control. Any way to get the controls to reset to display back at 0,0 and the bottom scroll bar to reset back to the left and the right one back to the top?
|
|
|
|
|
Hi guys what is wrong with this line? lookupObject is a struct. I just want to initialize the dictionary with the struct as value.
public static Dictionary<string, lookupojbect=""> dicTextLookup = new Dictionary<string, lookupojbect="">();
this is the error: "Error 1 Inconsistent accessibility: field type 'System.Collections.Generic.Dictionary<string,lookupojbect>' is less accessible than field 'dicTextLookup' C:\IL\TranslationController.cs 44"
Thanks
|
|
|
|
|
Could you repost that snippet, but check the "Ignore HTML tags in this message" checkbox when posting? We can't see your full code otherwise.
Is dicTextLookup non-public? Are you exposing the field as public? This error typically occurs if you're trying to expose some private/protected/internal thing as public. For instance
private class MyFoo {}
public class MyBar()
{
public MyFoo instance;
}
|
|
|
|
|
Sorry I didnt know about checking the checkbox, you solved my problem without looking at my code. Great!
|
|
|
|
|
How can I verify that the input in a textbox is numeric?
Jude
|
|
|
|
|
You could use a regular expression, something like RegEx("[0-9]")
only two letters away from being an asset
|
|
|
|
|
Could you point me in the right directioon on how to use RegEx?
Thanx
Jude
|
|
|
|
|
|
try to parse it, between try and catch and if rise exception isnt number
God make a perfect team, the rest have foreigners, Athletic Club Bilbao
|
|
|
|
|
How do I implement this method?
Jude
|
|
|
|
|
Don't implement it that way. Exceptions should be used only for exceptional circumstances, not part of normal code flow.
Rather than doing that, either us a MaskedTextBox (new in .NET 2.0) or use a regular expression to validate the input.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Messianic Instrumentals (with audio)
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
When using Framework 2.0 you could use MaskedTextBox .
"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
|
|
|
|
|
Include the Visual Basic library and use the IsNumeric method.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
|
|
Greeeg wrote: a sorted list via a listbox control
|
|
|
|
|
Here is an easy way that doesn't rely on exceptions, regular expressions, or legacy VB libraries:
double numericValue;
bool isNumeric = double.TryParse(myTextBox.Text, out numericValue);
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Messianic Instrumentals (with audio)
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Unfortunately there's no int.TryParse method to accompany that one.
|
|
|
|
|
|
Yes, there is an Int32.TryParse().
...or, at least I hope so, because I've used it...
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
dan neely wrote: Unfortunately there's no int.TryParse method to accompany that one.
Fortunately there are:
<br />
Int16.TryParse(string s,out short result)<br />
Int32.TryParse(string s, out int result)<br />
Int64.TryParse(string s,out long result)<br />
_____________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
U can just use a simle java script for that.
Vipin
|
|
|
|