Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello friends please help me

let my datagridview is like this.............

id    name   subject    Class
1     a       maths     11
2     b       maths     11
3     c       maths     12
4     d       maths     11
5     e       science   10
6     f       science   11
7     g       science   12
____________________________

Now I want to get a combo-box in column subject (which contain three values static value like maths ,science,arts..) only when user press enter key only....to chnage the subject of that particular student... I hope now you can understand my problem ...

please friend help me
what I have to do ...please help me ....


thanks in advanced

lakhan :(
Posted
Updated 3-Jan-12 4:03am
v2
Comments
[no name] 3-Jan-12 10:04am    
what?

you can use a panel. put your controls of datagrid into panel.

now on cellclick of datagrid

show your panel as popup and put update button on panel. After selecting a row in datagrid all data of that particular row will be on panel controls. after selecting subject when user clicks on update button update table and bind datagrid.
 
Share this answer
 
v2
HTML
<datagrid name="dgSales" height="300" margin="0,3,0,0" issynchronizedwithcurrentitem="True" selecteditem="{Binding SelectedItem,Converter={StaticResource ignoreNewItemPlaceHolderConverter}}" itemssource="{Binding StockList,UpdateSourceTrigger=PropertyChanged}" tooltip="{Binding RelativeSource={RelativeSource Self},Path=(Validation.Errors)[0].ErrorContent}" gotkeyboardfocus="dgSales_GotKeyboardFocus" currentcellchanged="dgSales_CurrentCellChanged" previewkeydown="dgSales_PreviewKeyDown">
	<datagrid.columns>
		<datagridtextcolumn header="S No." width="SizeToCells" minwidth="60" binding="{Binding SNo}" isreadonly="True" />
		<datagridtemplatecolumn header="Stock Name" width="280">
			<datagridtemplatecolumn.celltemplate>
				<datatemplate>
					<textblock text="{Binding StockName}" />
				</datatemplate>
			</datagridtemplatecolumn.celltemplate>
			<datagridtemplatecolumn.celleditingtemplate>
				<datatemplate>
					<combobox width="280" name="cmbStock" itemssource="{Binding Path=Stocks}" focusmanager.focusedelement="{Binding RelativeSource={RelativeSource Self}}"></combobox>
				</datatemplate>
			</datagridtemplatecolumn.celleditingtemplate>
		</datagridtemplatecolumn>
		<datagridtextcolumn header="Unit Price" width="SizeToCells" minwidth="80" binding="{Binding UnitPrice,UpdateSourceTrigger=LostFocus}" />
		<datagridtextcolumn header="Unit" width="SizeToCells" minwidth="80" binding="{Binding Unit}" isreadonly="True" />
		<datagridtextcolumn header="Quantity" width="SizeToCells" minwidth="80" binding="{Binding Quantity,UpdateSourceTrigger=LostFocus}" />
		<datagridtextcolumn header="Discount" width="SizeToCells" minwidth="80" binding="{Binding Discount,UpdateSourceTrigger=LostFocus}" />
		<datagridtextcolumn header="Amount" width="SizeToCells" minwidth="100" binding="{Binding Amount,StringFormat=\{0:n2\}}" isreadonly="True" />
	</datagrid.columns>
</datagrid>
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900